<!DOCTYPE html>
<html>
<head hexo-theme='https://github.com/volantis-x/hexo-theme-volantis/tree/4.0.0-rc.3'>
  <meta charset="utf-8">
  <!-- SEO相关 -->
  
    
  
  <!-- 渲染优化 -->
  <meta name="renderer" content="webkit">
  <meta name="force-rendering" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <meta name="HandheldFriendly" content="True" >
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta http-equiv='x-dns-prefetch-control' content='on' />

  <!-- 页面元数据 -->
  
  <title>Java基础语法 - DataScience</title>
  
    <meta name="keywords" content="Java">
  

  
    <meta name="description" content="Java基础语法">
  

  <!-- feed -->
  

  <!-- import meta -->
  

  <!-- link -->
  <link rel='dns-prefetch' href='https://cdn.jsdelivr.net'>
  
    
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/heson525/fontawesome-pro@5.13.1/css/all.min.css">

  
  

  

  
    <link rel="shortcut icon" type='image/x-icon' href="/favicon.ico">
  

  
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.10/dist/APlayer.min.css">
  

  

  <!-- import link -->
  

  
    
      
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10.2.0/styles/a11y-dark.css">

    
  
  
    
<link rel="stylesheet" href="/css/style.css">

  
  
  
  <!-- 脚本懒加载函数 -->
  <script>
  function loadScript(src, cb) {
    var HEAD = document.getElementsByTagName('head')[0] || document.documentElement;
    var script = document.createElement('script');
    script.setAttribute('type','text/javascript');
    if (cb) script.onload = cb;
    script.setAttribute('src', src);
    HEAD.appendChild(script);
  }
  //https://github.com/filamentgroup/loadCSS
  !function(c){"use strict";var e=function(e,t,n,r){var o,i=c.document,a=i.createElement("link");if(t)o=t;else{var d=(i.body||i.getElementsByTagName("head")[0]).childNodes;o=d[d.length-1]}var f=i.styleSheets;if(r)for(var l in r)r.hasOwnProperty(l)&&a.setAttribute(l,r[l]);a.rel="stylesheet",a.href=e,a.media="only x",function e(t){if(i.body)return t();setTimeout(function(){e(t)})}(function(){o.parentNode.insertBefore(a,t?o:o.nextSibling)});var s=function(e){for(var t=a.href,n=f.length;n--;)if(f[n].href===t)return e();setTimeout(function(){s(e)})};function u(){a.addEventListener&&a.removeEventListener("load",u),a.media=n||"all"}return a.addEventListener&&a.addEventListener("load",u),(a.onloadcssdefined=s)(u),a};"undefined"!=typeof exports?exports.loadCSS=e:c.loadCSS=e}("undefined"!=typeof global?global:this);
  </script>
  <script id="loadcss"></script>
</head>

<body>
  <header class="l_header auto shadow blur " style='opacity: 0' >
  <div class='container'>
  <div class='wrapper'>
    <div class='nav-sub'>
      <p class="title"></p>
      <ul class='switcher nav-list-h m-phone' id="pjax-header-nav-list">
        <li><a class="s-comment fas fa-comments fa-fw" target="_self" href='javascript:void(0)'></a></li>
        
          <li><a class="s-toc fas fa-list fa-fw" target="_self" href='javascript:void(0)'></a></li>
        
      </ul>
    </div>
		<div class="nav-main">
      
        
        <a class="title flat-box" target="_self" href='/'>
          
            <img no-lazy class='logo' src='https://7.dusays.com/2020/12/02/16aab31b3dcfe.png'/>
          
          
          
        </a>
      

			<div class='menu navigation'>
				<ul class='nav-list-h m-pc'>
          
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/
                  
                  
                  
                    id="home"
                  >
                  <i class='fal fa-home fa-fw'></i>首页
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fal fa-search fa-fw fa-fw'></i>发现
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://learngitbranching.js.org/?demo=&amp;locale=zh_CN
                  
                  
                  
                    id="https:learngitbranchingjsorg?demo=&amp;locale=zh_CN"
                  >
                  <i class='fas fa-pen-alt fa-fw'></i>Git
                </a>
                
              </li>
            
          
                    
                      
            
              <hr>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-palette fa-fw'></i>娱乐
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/mofang
                  
                  
                  
                    id="relaxmofang"
                  >
                  魔方
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/2048
                  
                  
                  
                    id="relax2048"
                  >
                  2048
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-fan fa-spin fa-fw'></i>社区
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/books/
                  
                  
                  
                    id="books"
                  >
                  <i class='fa fa-book fa-fw fa-fw'></i>悦读
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/movies/
                  
                  
                  
                    id="movies"
                  >
                  <i class='fas fa-play-circle fa-fw fa-fw'></i>电影
                </a>
                
              </li>
            
          
                    
                      
            
              
                <li>
                  <a class="menuitem flat-box">
                    <i class='fas fa-compact-disc fa-fw music'></i>音乐
                  </a>
                  <ul class="list-v">
                    <li>
                      <div class="aplayer-container">
                        

  
    <meting-js
      theme='#1BCDFC'
      volume='0.3'
      loop='all'
      order='random'
      fixed='false'
      list-max-height='320px'
      server='netease'
      type='playlist'
      id='5229739363'
      list-folded='true'>
    </meting-js>
  


                      </div>
                    </li>
                  </ul>
                <li>
              
            
          
                    
                  </ul>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-comment-dots fa-fw fa-fw'></i>聆听
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/contact/
                  
                  
                  
                    id="contact"
                  >
                  <i class='fa fa-paper-plane fa-fw fa-fw'></i>留言
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/Creator-said/
                  
                  
                  
                    id="Creator-said"
                  >
                  <i class='fas fa-comment-dots fa-fw fa-fw'></i>话痨
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fa fa-history fa-fw fa-fw'></i>关于
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/love
                  
                  
                  
                    id="relaxlove"
                  >
                  <i class='fa-fw fa fa-heart fa-fw'></i>表白
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/about/
                  
                  
                  
                    id="about"
                  >
                  <i class='fas fa-info-circle fa-fw fa-fw'></i>自述
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-ellipsis-v fa-fw'></i>更多
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  镜像
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirrors.163.com/
                  
                  
                  
                    id="http:mirrors163com"
                  >
                  网易
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirrors.sohu.com/ubuntu/indices/
                  
                  
                  
                    id="http:mirrorssohucomubuntuindices"
                  >
                  搜狐
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://mirrors.tuna.tsinghua.edu.cn/apache/
                  
                  
                  
                    id="https:mirrorstunatsinghuaeducnapache"
                  >
                  Apache
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  Centos
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://man.linuxde.net/download/CentOS
                  
                  
                  
                    id="http:manlinuxdenetdownloadCentOS"
                  >
                  国内
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.centos.org/download/
                  
                  
                  
                    id="https:wwwcentosorgdownload"
                  >
                  官方
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirror.lzu.edu.cn/
                  
                  
                  
                    id="http:mirrorlzueducn"
                  >
                  兰大
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  工具
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://encycolorpedia.cn/named
                  
                  
                  
                    id="https:encycolorpediacnnamed"
                  >
                  颜色码
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.iconfont.cn/
                  
                  
                  
                    id="https:wwwiconfontcn"
                  >
                  图标库
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.sojson.com/dwz.html
                  
                  
                  
                    id="https:wwwsojsoncomdwzhtml"
                  >
                  短链接
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://cli.im/
                  
                  
                  
                    id="https:cliim"
                  >
                  二维码1.4.14
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://www.aigei.com/bgremover/
                  
                  
                  
                    id="http:wwwaigeicombgremover"
                  >
                  透明图
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  站点
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://a2data.github.io/
                  
                  
                  
                    id="http:a2datagithubio"
                  >
                  Github
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://sqlsq_admin.gitee.io/
                  
                  
                  
                    id="https:sqlsq_admingiteeio"
                  >
                  Gitee
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
          
				</ul>
			</div>

      <div class="m_search">
        <form name="searchform" class="form u-search-form">
          <i class="icon fal fa-search fa-fw"></i>
          <input type="text" class="input u-search-input" placeholder="想找些什么~" />
        </form>
      </div>

			<ul class='switcher nav-list-h m-phone'>
				
					<li><a class="s-search fas fa-search fa-fw" target="_self" href='javascript:void(0)'></a></li>
				
				<li>
          <a class="s-menu fas fa-bars fa-fw" target="_self" href='javascript:void(0)'></a>
          <ul class="menu-phone list-v navigation white-box">
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/
                  
                  
                  
                    id="home"
                  >
                  <i class='fal fa-home fa-fw'></i>首页
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fal fa-search fa-fw fa-fw'></i>发现
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://learngitbranching.js.org/?demo=&amp;locale=zh_CN
                  
                  
                  
                    id="https:learngitbranchingjsorg?demo=&amp;locale=zh_CN"
                  >
                  <i class='fas fa-pen-alt fa-fw'></i>Git
                </a>
                
              </li>
            
          
                    
                      
            
              <hr>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-palette fa-fw'></i>娱乐
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/mofang
                  
                  
                  
                    id="relaxmofang"
                  >
                  魔方
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/2048
                  
                  
                  
                    id="relax2048"
                  >
                  2048
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-fan fa-spin fa-fw'></i>社区
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/books/
                  
                  
                  
                    id="books"
                  >
                  <i class='fa fa-book fa-fw fa-fw'></i>悦读
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/movies/
                  
                  
                  
                    id="movies"
                  >
                  <i class='fas fa-play-circle fa-fw fa-fw'></i>电影
                </a>
                
              </li>
            
          
                    
                      
            
              
            
          
                    
                  </ul>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-comment-dots fa-fw fa-fw'></i>聆听
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/contact/
                  
                  
                  
                    id="contact"
                  >
                  <i class='fa fa-paper-plane fa-fw fa-fw'></i>留言
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/Creator-said/
                  
                  
                  
                    id="Creator-said"
                  >
                  <i class='fas fa-comment-dots fa-fw fa-fw'></i>话痨
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fa fa-history fa-fw fa-fw'></i>关于
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/relax/love
                  
                  
                  
                    id="relaxlove"
                  >
                  <i class='fa-fw fa fa-heart fa-fw'></i>表白
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/about/
                  
                  
                  
                    id="about"
                  >
                  <i class='fas fa-info-circle fa-fw fa-fw'></i>自述
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  <i class='fas fa-ellipsis-v fa-fw'></i>更多
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  镜像
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirrors.163.com/
                  
                  
                  
                    id="http:mirrors163com"
                  >
                  网易
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirrors.sohu.com/ubuntu/indices/
                  
                  
                  
                    id="http:mirrorssohucomubuntuindices"
                  >
                  搜狐
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://mirrors.tuna.tsinghua.edu.cn/apache/
                  
                  
                  
                    id="https:mirrorstunatsinghuaeducnapache"
                  >
                  Apache
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  Centos
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://man.linuxde.net/download/CentOS
                  
                  
                  
                    id="http:manlinuxdenetdownloadCentOS"
                  >
                  国内
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.centos.org/download/
                  
                  
                  
                    id="https:wwwcentosorgdownload"
                  >
                  官方
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://mirror.lzu.edu.cn/
                  
                  
                  
                    id="http:mirrorlzueducn"
                  >
                  兰大
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  工具
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://encycolorpedia.cn/named
                  
                  
                  
                    id="https:encycolorpediacnnamed"
                  >
                  颜色码
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.iconfont.cn/
                  
                  
                  
                    id="https:wwwiconfontcn"
                  >
                  图标库
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://www.sojson.com/dwz.html
                  
                  
                  
                    id="https:wwwsojsoncomdwzhtml"
                  >
                  短链接
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://cli.im/
                  
                  
                  
                    id="https:cliim"
                  >
                  二维码1.4.14
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://www.aigei.com/bgremover/
                  
                  
                  
                    id="http:wwwaigeicombgremover"
                  >
                  透明图
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" 
                  
                  
                  >
                  站点
                </a>
                
                  <ul class="list-v">
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=http://a2data.github.io/
                  
                  
                  
                    id="http:a2datagithubio"
                  >
                  Github
                </a>
                
              </li>
            
          
                    
                      
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=https://sqlsq_admin.gitee.io/
                  
                  
                  
                    id="https:sqlsq_admingiteeio"
                  >
                  Gitee
                </a>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
                    
                  </ul>
                
              </li>
            
          
            
          </ul>
        </li>
			</ul>
		</div>
	</div>
  </div>
</header>

  <div class="l_body">
    <div class="l_cover">
  
    
    
        <div class='cover-wrapper post featured' style="display: none;">
          
            <div class='cover-bg lazyload placeholder' data-bg="https://7.dusays.com/2020/09/10/bcac99047bac5.png"></div>
          
          <div class='cover-body'>
  <div class='top'>
    
    
      <p class="title">数据科学</p>
    
    
      <p class="subtitle">Welcome To A2Data</p>
    
  </div>
  <div class='bottom'>
    <div class='menu navigation'>
      <div class='list-h'>
        
          
            <a href="/categories/"
              
              
              id="categories">
              <i class='fal fa-folder-open fa-fw fa-fw'></i><p>内容大纲</p>
            </a>
          
            <a href="/archives/"
              
              
              id="archives">
              <i class='fal fa-archive fa-fw fa-fw'></i><p>文章归档</p>
            </a>
          
            <a href="/tags/"
              
              
              id="tags">
              <i class='fal fa-fire fa-fw fa-fw fa-fw'></i><p>热门标签</p>
            </a>
          
            <a href="/contact/"
              
              
              id="contact">
              <i class='fal fa-comments fa-fw fa-fw'></i><p>畅所欲言</p>
            </a>
          
            <a href="/Creator-said/"
              
              
              id="Creator-said">
              <i class='fal fa-microphone-alt fa-fw fa-fw'></i><p>随便说说</p>
            </a>
          
            <a href="/friends/"
              
              
              id="friends">
              <i class='fal fa-link fa-fw fa-fw'></i><p>我的朋友</p>
            </a>
          
        
      </div>
    </div>
  </div>
</div>

          <div class="scroll-down" style="display: none;"><i class="fa fa-chevron-down scroll-down-effects"></i></div>
        </div>
    
  
  </div>
  
    <div class='safearea'>
      <div class='body-wrapper' id="pjax-container">
        
          <!--此文件用来存放一些不方便取值的变量--> 
<!--思路大概是将值藏到重加载的区域内--> 
 
 
 
<div id="pjax-data" style="display: none"> 
  <div id="pjax-ispage">true</div> 
  <div id="pjax-pageTitle">Java基础语法</div> 
  <div id="pjax-enable-cover">true</div> 
  <div id="pjax-comment-path"></div> 
  <div id="pjax-comment-placeholder"></div> 
</div> 
 
 
<script> 
  // 处理封面 此时 jquery 还没加载 
  if ("none" == "none") { // 移除封面 
    document.getElementsByClassName('cover-wrapper')[0].style.display = "none"; 
    document.getElementsByClassName('l_header', 'cover-wrapper')[0].classList.add("show"); 
  } else { 
    if ("none" == "half") { // 半屏 
      document.getElementsByClassName('cover-wrapper')[0].setAttribute('id', 'half'); 
      document.getElementsByClassName('scroll-down')[0].style.display = "none"; 
    } else if ("none" == "full") { // 全屏 
      document.getElementsByClassName('cover-wrapper')[0].setAttribute('id', 'full'); 
      document.getElementsByClassName('scroll-down')[0].style.display = ""; 
    } 
    document.getElementsByClassName('cover-wrapper')[0].style.display = ""; 
    document.getElementsByClassName('l_header', 'cover-wrapper')[0].classList.remove("show"); 
  } 
</script> 
 

        
        

<div class='l_main'>
  <article class="article post white-box reveal md shadow article-type-post" id="post" itemscope itemprop="blogPost">
  


  
  <div class="article-meta" id="top">
    
    
      <a title='Java基础语法' href='/posts/34708.html'>
        <img class='thumbnail' src='https://gitee.com/DataITems/cdn/raw/master/20200508000334.png'>
      </a>
    
    
      <h1 class="title">
        Java基础语法
      </h1>
      <div class='new-meta-box'>
        
          
            
<div class='new-meta-item author'>
  <a class='author' href="/" rel="nofollow">
    <img no-lazy src="https://gitee.com/DataITems/cdn/raw/master/avatar.png">
    <p>JackFeng</p>
  </a>
</div>

          
        
          
            <div class="new-meta-item date">
  <a class='notlink'>
    <i class="fas fa-calendar-alt fa-fw" aria-hidden="true"></i>
    <p>发布于：May 7, 2020</p>
  </a>
</div>

          
        
          
            
  <div class='new-meta-item category'>
    <a class='notlink'>
      <i class="fas fa-folder-open fa-fw" aria-hidden="true"></i>
      <a class="category-link" href="/categories/Java/">Java</a>
    </a>
  </div>


          
        
          
            
  <div class="new-meta-item wordcount">
    <a class='notlink'>
      <i class="fas fa-keyboard fa-fw" aria-hidden="true"></i>
      <p>8.6k words</p>
    </a>
  </div>
  <div class="new-meta-item readtime">
    <a class='notlink'>
      <i class="fas fa-hourglass-half fa-fw" aria-hidden="true"></i>
      <p>40 min</p>
    </a>
  </div>


          
        
          
            
  <div class="new-meta-item browse leancloud">
    <a class='notlink'>
      
      <div id="lc-pv" data-title="Java基础语法" data-path="/posts/34708.html">
        <i class="fas fa-eye fa-fw" aria-hidden="true"></i>
        <span id='number'><i class="fas fa-circle-notch fa-spin fa-fw" aria-hidden="true"></i></span>
        次浏览
      </div>
    </a>
  </div>


          
        
          
            
<div class="new-meta-item comments-count">
  
  <a href="/posts/34708.html#comments">
    <i class="fas fa-comment-dots fa-fw"></i>
    <span class="valine-comment-count" data-xid="/posts/34708.html">0</span>
    <span class="leancloud-comments-count">&nbsp;</span>
  </a>
</div>


          
        
      </div>
    
  </div>


  
  
  <p>Java基础语法</p>
<a id="more"></a>


<h1 id="1、基础语法"><a href="#1、基础语法" class="headerlink" title="1、基础语法"></a>1、基础语法</h1><p><strong>Hello Wolrd</strong></p>
<blockquote>
<ul>
<li><p>首先定义类</p>
<p>—— public class  类名</p>
</li>
<li><p>在类定义之后加上一对大括号</p>
<p>—— {}</p>
</li>
<li><p>在大括号中间添加一个主(main)方法/函数</p>
<p>—— public static void main(String[] args){}</p>
</li>
<li><p>在主方法的大括号中间添加一行输出语句</p>
<p>—— System.out.println(“Hello World”)</p>
</li>
</ul>
<ul>
<li><p>完整代码</p>
</li>
<li><pre><code class="java">public class HelloWorld&#123;
public class static void main(String[] args)&#123;
    System.out.println(&quot;Hello World!&quot;)
    &#125;
&#125;
</code></pre>
</li>
<li><p>Javac —— 编译  javac HelloWorld.java</p>
</li>
<li><p>Java + HelloWorld 运行</p>
</li>
</ul>
</blockquote>
<p><strong>初学者注意事项</strong></p>
<blockquote>
<ul>
<li><p>单词拼写问题</p>
<p>— class      &gt;   Class</p>
<p>— String     &gt;   string</p>
<p>— System   &gt;  system</p>
<p>— main       &gt;   mian</p>
</li>
<li><p>中文符合问题</p>
<p>— 提示非法字符</p>
</li>
</ul>
</blockquote>
<h2 id="1-1、Java入门"><a href="#1-1、Java入门" class="headerlink" title="1.1、Java入门"></a>1.1、Java入门</h2><h3 id="1-1-0、注释"><a href="#1-1-0、注释" class="headerlink" title="1.1.0、注释"></a>1.1.0、注释</h3><blockquote>
<p>注释</p>
<p>//           #单行注释 </p>
<p>/*…*/     #多行注释</p>
<p>/...*/     #文本注释</p>
<p>JAVA 语句用 ； 分号结束。</p>
<p>命名</p>
<p>A、类：首字母大写</p>
<p>B、方法/函数：首字母小写第二个单词首字母大写</p>
<p>C、变量： 首字母小写第二个单词首字母大写</p>
<p>D、常量：全部字母大写</p>
<h6 id="标识符"><a href="#标识符" class="headerlink" title="标识符"></a>标识符</h6><p>程序员对程序中的各个元素加以命名时，使用的命名记号，称为标识符。</p>
<p>标识符以字母 下划线（__） 美元符（$）开始的一个字符序列，</p>
<p>后可跟 字母，下划线，美元符，数字。</p>
</blockquote>
<h3 id="1-1-1、关键字"><a href="#1-1-1、关键字" class="headerlink" title="1.1.1、关键字"></a>1.1.1、关键字</h3><blockquote>
<p>JAVA关键字(保留字）*</p>
<table>
<thead>
<tr>
<th>abstract</th>
<th>default</th>
<th>if</th>
<th>private</th>
<th>this</th>
</tr>
</thead>
<tbody><tr>
<td>boolean</td>
<td>do</td>
<td>implements</td>
<td>protected</td>
<td>throw</td>
</tr>
<tr>
<td>break</td>
<td>double</td>
<td>impor</td>
<td>public</td>
<td>throws</td>
</tr>
<tr>
<td>byte</td>
<td>else</td>
<td>instanceof</td>
<td>return</td>
<td>transient</td>
</tr>
<tr>
<td>case</td>
<td>extends</td>
<td>int</td>
<td>short</td>
<td>try</td>
</tr>
<tr>
<td>catch</td>
<td>final</td>
<td>interface</td>
<td>statictfp</td>
<td>volatile</td>
</tr>
<tr>
<td>char</td>
<td>finally</td>
<td>long</td>
<td>strictfp</td>
<td>volatile</td>
</tr>
<tr>
<td>class</td>
<td>float</td>
<td>native</td>
<td>super</td>
<td>while</td>
</tr>
<tr>
<td>const</td>
<td>for</td>
<td>new</td>
<td>switch</td>
<td>null</td>
</tr>
<tr>
<td>continue</td>
<td>goto</td>
<td>package</td>
<td>synchronized</td>
<td></td>
</tr>
</tbody></table>
</blockquote>
<h3 id="1-1-2、常量"><a href="#1-1-2、常量" class="headerlink" title="1.1.2、常量"></a>1.1.2、常量</h3><blockquote>
<p>常量：程序执行中，值不可发生改变</p>
<p>变量：在程序执行中，值会发生变化</p>
<ul>
<li><p>常量分类</p>
<p>——   A： 字符串常量 ‘DataScience’</p>
<p>——   B： 整数常量  123</p>
<p>——   C： 小数常量 1.23</p>
<p>——   D： 字符常量  ‘a’,’1’</p>
<p>——   E： 布尔常量  true ,false<br>——   F： 空常量 （null、’’)</p>
</li>
</ul>
</blockquote>
<pre><code class="java">public class CL&#123;
    public static void main(String[] args)&#123;
        // 字符串常量
        System.out.println(&quot;DataScience&quot;)

        // 整数常量
        System.out.println(123)

        // 小数常量
        System.out.println(1.23)        

            // 字符串量
        System.out.println(&quot;Data&quot;)        

            // 布尔常量
        System.out.println(true)

    &#125;
&#125;

</code></pre>
<h3 id="1-1-3、变量"><a href="#1-1-3、变量" class="headerlink" title="1.1.3、变量"></a>1.1.3、变量</h3><blockquote>
<p>变量的申明：</p>
<p>访问[修饰符] 数据类型 变量名称=初始值</p>
<p>变量的分类：<br>1、按照声明位置：<br>    成员变量：<br>            类的内部，方法的外部定义的变量<br>    局部变量：<br>            方法或代码块的内部定义的变量<br>        区别：<br>            成员变量有默认初始值，局部变量没有<br>            成员变量的作用域在整个类的内部，局部变量在当前方法或代码块中</p>
</blockquote>
<p><strong>变量实例：</strong></p>
<pre><code class="java">/**
 * Created by JackFeng on 2019/8/28.
 */

/*
* 常量: 在程序的执行过程中，其值不可以发生改变的量
*
* 常量的分类：
*   A： 字符串常量
*   B： 整数常量
*   C： 小数常量
*   D： 字符常量
*   E： 布尔常量  true ,false
*   F： 空常量
*
* */
public class Variable &#123;
    public static void main(String[] args) &#123;
        // A
        System.out.println(&quot;欢迎关注公众号DataScience&quot;);

        // B
        System.out.println(12);
        System.out.println(-66);

        // C
        System.out.println(23.56);

        //D
        System.out.println(&#39;a&#39;);

        // E
        System.out.println(true);
    &#125;
&#125;
</code></pre>
<h3 id="1-1-4、数据类型"><a href="#1-1-4、数据类型" class="headerlink" title="1.1.4、数据类型"></a>1.1.4、数据类型</h3><blockquote>
<p><em>数据类型</em>    —— Java是强类型语言，针对每一种数据都给出了明确的数据类型。</p>
<p><em>数据类型分类</em>：</p>
<ul>
<li>A：基本数据类型</li>
<li>B：引用数据类型 （类、接口、数组）</li>
</ul>
<p><em>基本数据类型（以及占用字节数）</em></p>
<ul>
<li>A、整数<ul>
<li>byte      <strong>1</strong></li>
<li>short     <strong>2</strong></li>
<li>int         <strong>4</strong></li>
<li>long      <strong>8</strong> </li>
</ul>
</li>
<li>B、浮点数<ul>
<li>float      <strong>4</strong></li>
<li>double  <strong>8</strong></li>
</ul>
</li>
<li>C、字符<ul>
<li>char      <strong>2</strong></li>
</ul>
</li>
<li>D、布尔<ul>
<li>boolean <strong>1</strong></li>
</ul>
</li>
</ul>
<p><em>注意</em></p>
<ul>
<li>A：整数默认是int类型，浮点数默认是double类型</li>
<li>B：<ul>
<li>定义long类型数据的时候，要加L或者l，建议加L</li>
<li>定义float类型数据的时候，要加F或者f，建议加F</li>
</ul>
</li>
</ul>
</blockquote>
<p><img src="https://cdn.jsdelivr.net/gh/A2Data/cdn/img/%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/A2Data/cdn/img/%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B.png" srcset="" alt="数据类型"></p>
<h5 id="整型变量"><a href="#整型变量" class="headerlink" title="整型变量"></a>整型变量</h5><table>
<thead>
<tr>
<th>类型</th>
<th>占用储存空间</th>
<th>表数范围</th>
</tr>
</thead>
<tbody><tr>
<td>byte</td>
<td>1字节</td>
<td>-128~127</td>
</tr>
<tr>
<td>short</td>
<td>2字节</td>
<td>-2^15~2^15-1</td>
</tr>
<tr>
<td>int</td>
<td>4字节</td>
<td>-2^31~2^31-1</td>
</tr>
<tr>
<td>long</td>
<td>8字节</td>
<td>-2^63~2^63-1</td>
</tr>
</tbody></table>
<h5 id="浮点型变量"><a href="#浮点型变量" class="headerlink" title="浮点型变量"></a>浮点型变量</h5><table>
<thead>
<tr>
<th>类型</th>
<th>占用储存空间</th>
<th>表数范围</th>
</tr>
</thead>
<tbody><tr>
<td>float</td>
<td>4字节</td>
<td>-3.403E38~3.403E38</td>
</tr>
<tr>
<td>double</td>
<td>8字节</td>
<td>-1.798E308~1.798E308</td>
</tr>
</tbody></table>
<blockquote>
<p>字符型变量： char  一个字符2字节</p>
<p>布尔型变量： true false</p>
<p>符号常量 final 变量类型 变量名=初始化值</p>
</blockquote>
<h5 id="值常量"><a href="#值常量" class="headerlink" title="值常量"></a>值常量</h5><p><em>整型常量、浮点型常量、符号型常量、字符串常量、布尔型常量（true false） 空常量</em></p>
<table>
<thead>
<tr>
<th>转义字符</th>
<th>含义</th>
</tr>
</thead>
<tbody><tr>
<td>\b</td>
<td>退格（backspace）</td>
</tr>
<tr>
<td>\t</td>
<td>水平制表（Tab）</td>
</tr>
<tr>
<td>\f</td>
<td>走纸换页，只对打印有效</td>
</tr>
<tr>
<td>\n</td>
<td>换行</td>
</tr>
<tr>
<td>\r</td>
<td>回车</td>
</tr>
<tr>
<td>\</td>
<td>反斜杠字符</td>
</tr>
<tr>
<td>&#39;</td>
<td>单引号字符</td>
</tr>
<tr>
<td>&quot;</td>
<td>双引号字符</td>
</tr>
<tr>
<td>\ddd</td>
<td>1–3位八进制数所代表的ASCII字符</td>
</tr>
<tr>
<td>\uxxxx</td>
<td>1-4位十六进制数所代表的unicode字符</td>
</tr>
</tbody></table>
<h3 id="1-1-5、-计算机存储单元"><a href="#1-1-5、-计算机存储单元" class="headerlink" title="1.1.5、 计算机存储单元"></a>1.1.5、 计算机存储单元</h3><blockquote>
<p>bit(比特位) —–字节（byte）</p>
<p>单位换算：</p>
<ul>
<li>1B(字节)  = 8it</li>
<li>1KB = 1024B</li>
<li>1MB = 1024KB</li>
<li>1GB = 1024MB</li>
<li>1TB = 1024GB</li>
<li>1PB = 1024TB</li>
<li>1ZB = 1024PB</li>
</ul>
</blockquote>
<h3 id="1-1-6、标识符"><a href="#1-1-6、标识符" class="headerlink" title="1.1.6、标识符"></a>1.1.6、标识符</h3><pre><code class="java">标识符： 包、类、方法、变量 等起名字的符号

组成规则：
    A：unicode 字符
        数字字符，英文大小写字母，汉字（不建议使用汉字）
    B：下划线 _
    C：美元符 $

注意事项：
    A: 不能以数字开头
    B：不能是Java中的关键字

常见命名规则：
    A：基本要求
        见名知意
    B：常见的命名
        1、包（其实就是文件夹，用于对类进行管理）
            全部小写，多级包.隔开
            EG: com， com.datascience
        2、类
            单个单词首字母大写
            EG:Dog
            多个单词首字母大写
            EG:BigDog
        3、方法和变量
            单个单词首字母小写
            EG： dog
            多个单词组成第二个开始首字母大写
            EG: bigDog,maxAge</code></pre>
<h3 id="1-1-7、运算符优先级"><a href="#1-1-7、运算符优先级" class="headerlink" title="1.1.7、运算符优先级"></a>1.1.7、运算符优先级</h3><table>
<thead>
<tr>
<th>优先级</th>
<th>运算符</th>
<th>结合性</th>
</tr>
</thead>
<tbody><tr>
<td>1</td>
<td>（） [ ]  .</td>
<td>从左向右</td>
</tr>
<tr>
<td>2</td>
<td>！ +（正） -（负） ~ ++ –</td>
<td>从右向左</td>
</tr>
<tr>
<td>3</td>
<td>/   *   %</td>
<td>从左向右</td>
</tr>
<tr>
<td>4</td>
<td>+ (加)  -（减）</td>
<td>从左向右</td>
</tr>
<tr>
<td>5</td>
<td>《 》 &gt;&gt;&gt;</td>
<td>从左向右</td>
</tr>
<tr>
<td>6</td>
<td>&lt;&lt;=&gt;&gt;  instanceof</td>
<td>从左向右</td>
</tr>
<tr>
<td>7</td>
<td>== ！=</td>
<td>从左向右</td>
</tr>
<tr>
<td>8</td>
<td>&amp; （按位与）</td>
<td>从左向右</td>
</tr>
<tr>
<td>9</td>
<td>^</td>
<td>从左向右</td>
</tr>
<tr>
<td>10</td>
<td>|</td>
<td>从左向右</td>
</tr>
<tr>
<td>11</td>
<td>&amp;&amp;</td>
<td>从左向右</td>
</tr>
<tr>
<td>12</td>
<td>||</td>
<td>从左向右</td>
</tr>
<tr>
<td>13</td>
<td>?:</td>
<td>从右向左</td>
</tr>
<tr>
<td>14</td>
<td>= += -= *= /= %= &amp;= |= ^= ~= &lt;&lt;= &gt;&gt;= &gt;&gt;&gt;=</td>
<td>从右向左</td>
</tr>
</tbody></table>
<h2 id="1-2、基本类型数据转换"><a href="#1-2、基本类型数据转换" class="headerlink" title="1.2、基本类型数据转换"></a>1.2、基本类型数据转换</h2><h3 id="1-2-1、定义变量"><a href="#1-2-1、定义变量" class="headerlink" title="1.2.1、定义变量"></a>1.2.1、定义变量</h3><pre><code class="java">变量格式：
    数据类型 变量名 = 初始化值

数据类型：
    byte,short,int,long,float,double,char,boolean</code></pre>
<p><strong>Demo</strong></p>
<pre><code class="java">public class VariableDemo &#123;
/*
* 变量的定义
* */

public static void main(String[] args)&#123;
//         定义byte 类型
        byte a = 10;
        System.out.println(10);
        System.out.println(a);

//        定义 short类型
        short b = 11;
        System.out.println(b);

//        定义int类型
        int c = 12;
        System.out.println(c);

//        定义long类型
        long d = 1231L;
        System.out.println(d);


//        定义float类型
        float e = 1.23F;
        System.out.println(e);

//        定义double类型
        double f = 1.23;
        System.out.println(f);

//        定义char类型
        char g = &#39;a&#39;;
        System.out.println(g);

//        定义boolean类型
        boolean h = true;
        System.out.println(h);

        &#125;
&#125;
</code></pre>
<h3 id="1-2-2、变量定义的注意事项"><a href="#1-2-2、变量定义的注意事项" class="headerlink" title="1.2.2、变量定义的注意事项"></a>1.2.2、变量定义的注意事项</h3><pre><code class="java">package one;

/**
 * Created by JackFeng on 2020/2/22.
 */
public class BianLiang &#123;
    /*
    * 变量定义的注意事项
    *   A: 变量未赋值，不能直接使用
    *   B：变量只在所属的范围内有效（仅在它所在的大括号中有效）
    *   C: 一行可以多个变量（不建议）
    * */
    public static void main(String[] args)&#123;

//        定义变量aa、
        int aa = 2020;
        System.out.println(aa);

        &#123;
//            大括号中的就是代码块
            int ab = 131;
            System.out.println(ab);
        &#125;

//        定义多个变量
        int a1, a2;
        a1 =11;
        a2 = 20;

        System.out.println(a1);
        System.out.println(a2);

    &#125;

&#125;
</code></pre>
<h3 id="1-2-3、类型转化"><a href="#1-2-3、类型转化" class="headerlink" title="1.2.3、类型转化"></a>1.2.3、类型转化</h3><pre><code class="java">package one;

/**
 * Created by JackFeng on 2020/2/25.
 */


/*
*  +:  加法运算符
*
*  运算中，要求参与运算的数据类型必须一致
*
*
*   类型转化：
*       隐式转化
*       强制转化
*           隐式转化：
*               byte,short,char  -- int --long  --float --double
*               byte+ int === int 类型
*           强制转化：
*               目标类型  变量名 = （目标类型）（被转化的数据）
*               建议：数据做运算，最好以结果类型为准（不要随意转化，否则可能损失精度）
*               int a = 10;
*               byte b = 20;
*               int c = a+b
*
*               byte d = (byte)(a + b)
*
*
* */
public class TypeCastDemo &#123;
    public static void main(String[] args) &#123;

//       1、 定义同类型变量
        int a = 11;
        int b = 22;

        int c = a + b;
        System.out.println(c);

//        定义一个 byte 类型 一个int类型
        int a1 = 10;
        byte a2 = 20;
        System.out.println(a1+a2);
    &#125;

&#125;
</code></pre>
<h3 id="1-2-4、运算符"><a href="#1-2-4、运算符" class="headerlink" title="1.2.4、运算符"></a>1.2.4、运算符</h3><h4 id="1-2-4-1、运算符"><a href="#1-2-4-1、运算符" class="headerlink" title="1.2.4.1、运算符"></a>1.2.4.1、运算符</h4><blockquote>
<p>运算符： 用于    常量和变量操作的符号</p>
<p>表达式：用运算符号链接起来符合java语法的句子</p>
<p>​      EG:  a,b    a+b</p>
</blockquote>
<h4 id="1-2-4-2、运算符分类"><a href="#1-2-4-2、运算符分类" class="headerlink" title="1.2.4.2、运算符分类"></a>1.2.4.2、运算符分类</h4><h5 id="1、算术运算符"><a href="#1、算术运算符" class="headerlink" title="1、算术运算符"></a>1、算术运算符</h5><blockquote>
<p>+，-，*，/ ，%，++，–</p>
</blockquote>
<p>*<em>+，-，</em>，/** </p>
<pre><code class="java">    //    +,-,*,/ 使用
//    定义变量
    int a = 3;
    int b = 4;
    System.out.println(a+b);
    System.out.println(a-b);
    System.out.println(a*b);
    System.out.println(a/b);

//    整数相除 只能得到整数，要想得到小数 必须有浮点数参与运算
    System.out.println(3.0/4);
    System.out.println(3/4.0);
</code></pre>
<p><strong>% (取余)</strong></p>
<blockquote>
<p> *%*：用于获取 两个数据相除时候的余数</p>
<p> */*： 用于获取 两个数据相除时候的商</p>
</blockquote>
<pre><code class="java">    int a1=3;
    int a2=5;

    System.out.println(a2/a1);
    System.out.println(a2%a1);    </code></pre>
<p><strong>+</strong></p>
<blockquote>
<p>+：    加法运算</p>
<ul>
<li><p>正常加法运算</p>
<ul>
<li>int a =10; </li>
<li>int b = 12;</li>
</ul>
</li>
<li><p>字符参与加法运算，是拿字符在计算机中存储的数据值来参与运算的</p>
<ul>
<li>“A”  65</li>
<li>‘a’  97</li>
<li>‘0’ 48</li>
</ul>
</li>
<li><p>字符串参与加法运算，其实不是做加法，而是字符串的拼接</p>
<ul>
<li><p>例如： int a =1; int b =2;</p>
</li>
<li><p>System.out.println(“hello”+a)</p>
<ul>
<li>hello1</li>
</ul>
<p>System.out.println(a+b+”hello”)</p>
<p>​        3hello</p>
</li>
</ul>
</li>
<li><p><strong>注意</strong> 执行顺序（会对结果产生影响）： 从左–&gt;右</p>
</li>
</ul>
</blockquote>
<p><strong>++，–</strong></p>
<blockquote>
<p>++，– ： 自增自减，用于对变量+1 或 -1</p>
<ul>
<li>单独使用：<ul>
<li>放在变量前后都可以，结果一样</li>
</ul>
</li>
<li>其它操作：<ul>
<li>++ 在后边，先拿变量做操作，然后变量再++</li>
<li>++ 在前边，先变量++，再拿变量做操作</li>
</ul>
</li>
</ul>
</blockquote>
<pre><code class="java">package myOperator;

/**
 * Created by JackFeng on 2020/2/25.
 */

/*
* ++ -- : 自增自减
*
* */
public class OpeartorDemo1 &#123;
    public static void main(String[] args) &#123;

//        定义变量
        int a = 123;
        System.out.println(&quot;a:&quot;+a);

//        ++
        int b = a++;
        System.out.println(&quot;a:&quot;+a);
        System.out.println(&quot;b:&quot;+b);

        int c = ++a;
        System.out.println(&quot;a:&quot;+a);
        System.out.println(&quot;c:&quot;+c);

    &#125;
&#125;
</code></pre>
<h5 id="2、赋值运算符"><a href="#2、赋值运算符" class="headerlink" title="2、赋值运算符"></a>2、赋值运算符</h5><blockquote>
<p>赋值运算符：</p>
<ul>
<li>基本赋值运算符：=</li>
<li>扩展赋值运算符：+=，-=，*=，/=,…..</li>
</ul>
</blockquote>
<pre><code class="java">package myOperator;

/**
 * Created by JackFeng on 2020/2/25.
 */
/*
* 赋值运算符：
*   基本的赋值运算符： =
*   扩展的赋值运算符： +=，-=，*=，/= ...
*
* */


public class OpeartorDemo2 &#123;

    public static void main(String[] args) &#123;

//        定义变量
        int a = 25; // 把 25 赋值给int 类型的变量a

//        += 操作
//        拿+= 左边和右边的数据做 加法，然后赋值给左边
        a += 5;
        System.out.println(a);

//        注意： 扩展的赋值运算符,隐含了 强制类型转换
//        有一个变量 a,  a+=5;
//        相当于： a=(a的数据类型)(a+5)

        short s = 1;
        s += 1;
        System.out.println(s);

    &#125;
&#125;
</code></pre>
<h5 id="3、关系运算符"><a href="#3、关系运算符" class="headerlink" title="3、关系运算符"></a>3、关系运算符</h5><blockquote>
<p>关系运算符：</p>
<ul>
<li>==， !=，&gt;,&gt;=,&lt;,&gt;=</li>
<li>关系运算符结果是 boolean类型.（false/true）</li>
</ul>
<p>注意事项：</p>
<ul>
<li>不要把两个== 写成 = （除非你赋值）</li>
</ul>
</blockquote>
<h5 id="4、逻辑运算符"><a href="#4、逻辑运算符" class="headerlink" title="4、逻辑运算符"></a>4、逻辑运算符</h5><blockquote>
<p>逻辑运算符：</p>
<ul>
<li>释义：用于链接关系表达式</li>
<li>逻辑运算分类：<ul>
<li>&amp;，|，^,!</li>
<li>&amp;&amp;, ||</li>
</ul>
</li>
</ul>
</blockquote>
<p><strong>&amp;（或）</strong></p>
<blockquote>
<p>有false 则false</p>
</blockquote>
<p><strong>|（与）</strong></p>
<blockquote>
<p>有true则true</p>
</blockquote>
<p><strong>^（异或）</strong></p>
<blockquote>
<p>相同则false，不同则true </p>
</blockquote>
<p><strong>！（非）</strong></p>
<blockquote>
<p>true则false，false 则 true</p>
</blockquote>
<p><strong>&amp;&amp;</strong></p>
<blockquote>
<p>&amp;&amp; 和 &amp; 的结果一样</p>
<p>&amp;&amp; 与 &amp; 的区别：</p>
<ul>
<li>&amp;&amp; 有短路效果，左边为false，右边不执行</li>
<li>&amp; 左边无论是什么，右边都会执行</li>
</ul>
</blockquote>
<p><strong>||</strong></p>
<blockquote>
<p>|| 和 | 的结果一样</p>
<p>|| 与 | 的区别：</p>
<ul>
<li>|| 左边为true ，右边不执行</li>
<li>| 左边无论是啥，右边都执行</li>
</ul>
</blockquote>
<h5 id="5、三元运算符"><a href="#5、三元运算符" class="headerlink" title="5、三元运算符"></a>5、三元运算符</h5><blockquote>
<p>三元运算符：</p>
<ul>
<li>关系表达式？表达式1：表达式2</li>
</ul>
<p>执行流程：</p>
<ul>
<li>A： 计算关系表达式的值（true/false）</li>
<li>B:    结果展示<ul>
<li>如果是true，表达式1就是结果</li>
<li>如果是false，表达式2就是结果</li>
</ul>
</li>
</ul>
</blockquote>
<pre><code class="java">       // 三元运算符

        int aa = 10;
        int bb = 20;

        int cc = (aa &gt; bb) ? aa : bb;
        System.out.println(&quot;====&quot;);
        System.out.println(&quot;cc&quot;+cc);

        //输出
        ====
        cc:20
</code></pre>
<p><strong>案例：取三个数中的最大值</strong></p>
<pre><code class="java">        // 获取三个数的最大值

        int q = 11;
        int w = 12;
        int e = 22;

        // 先获取两个数据的最大值,然后再和第三个数据比较即可

        int temp = (q &gt; w) ? q : w;
        int max = (temp &gt; e) ? temp : e;
        System.out.println(&quot;+++++++++&quot;);
        System.out.println(&quot;max:&quot;+max);</code></pre>
<h3 id="1-2-5、键盘录入"><a href="#1-2-5、键盘录入" class="headerlink" title="1.2.5、键盘录入"></a>1.2.5、键盘录入</h3><pre><code class="java">package myScanner;

/**
 * Created by JackFeng on 2020/2/25.
 */

/*
*
* 键盘录入：
* 如何实现？ JDK提供的类Scanner
* 使用步骤：
*       A: 导包
*          import java.util.Scanner;
*          在一个类中顺序： package &gt; import &gt; class
*       B: 创建键盘录入对象
*          Scanner sc = new Scanner(System.in)
*       C: 接受数据
*           int i = sc.nextInt();
*
*
*
* */

import java.util.Scanner;

public class ScannerDemo &#123;
    public static void main(String[] args) &#123;

        Scanner sc = new Scanner(System.in);

        System.out.println(&quot;请输入数据： &quot;);
        int i = sc.nextInt();




        System.out.println(&quot;i:&quot;+i);

    &#125;

&#125;
</code></pre>
<p><strong>录入数据求和</strong></p>
<pre><code class="java">        // 录入数据 并且求和
        System.out.println(&quot;请输入第一个数据： &quot;);
        int aa = sc.nextInt();

        System.out.println(&quot;请输入第二个数据： &quot;);
        int bb = sc.nextInt();

        // 数据求和
        int sum = aa + bb;

        System.out.println(&quot;sum:&quot;+sum);


        // 比较两个数据是否相等

//        boolean flag = (aa == bb) ? true : false;
        boolean flag = (aa == bb);

        System.out.println(flag);

        // 录入三个数据,三个数据的最大值

        System.out.println(&quot;请输入第三个数据： &quot;);
        int cc = sc.nextInt();

        int temp = (aa &gt; bb) ? aa : bb;

        int max = (temp&gt;cc)?temp:cc;

        System.out.println(&quot;max:&quot;+max);</code></pre>
<h3 id="1-2-6、流程控制语句"><a href="#1-2-6、流程控制语句" class="headerlink" title="1.2.6、流程控制语句"></a>1.2.6、流程控制语句</h3><p><strong>顺序结构</strong></p>
<blockquote>
<p>从上往下，依次执行！</p>
</blockquote>
<p><strong>选择结构</strong></p>
<blockquote>
<p>if语句：</p>
<ul>
<li><p>if(关系表达式){</p>
<p>​    语句体 </p>
<p>}</p>
</li>
</ul>
<ul>
<li><p>执行流程</p>
<ul>
<li>A: 首先计算关系表达式的值，看是true/false</li>
<li>B: 如果是true，就执行语句体</li>
<li>C: 如果是False，则不执行</li>
</ul>
</li>
</ul>
<pre><code class="java">    // if 关系表达式

    int    a = 10;
    int b = 20;

    if(a==b)&#123;
        System.out.print(&quot;a=b&quot;)
    &#125;

    int c = 10;

    if(a==c)&#123;
        System.out.println(&quot;a=c&quot;)
    &#125;</code></pre>
<ul>
<li><p>if(关系表达式){</p>
<p>​    语句体1;</p>
<p>}else{</p>
<p>​    语句体2;</p>
<p>}</p>
</li>
</ul>
<pre><code class="java">        // 判断一个数 是偶数还是奇数

        int a = 100;
        // 重新给a赋值
        a = 99;

        if(a%2 ==0)&#123;
            System.out.println(&quot;a为偶数&quot;);
        &#125;else&#123;
            System.out.println(&quot;a为奇数&quot;);
        &#125;</code></pre>
<ul>
<li><p>if(关系表达式1){</p>
<p>​    语句体1;</p>
<p>}else if(关系表达式2){</p>
<p>​    语句体2;</p>
<p>}</p>
<p>…</p>
<p>else{</p>
<p>​    语句体n+1;</p>
<p>}</p>
</li>
</ul>
<pre><code class="java"> // 多个if 表达式



        int x = 10;
        int y;

        if (x &gt;= 3)&#123;
            y = 2 * x + 1;
        &#125; else if (x &gt;= -1 &amp;&amp; x&lt;3)&#123;
            y = 2 * x;
        &#125;else if (x &lt;= -1)&#123;
            y = 2 * x - 1;
        &#125;else &#123;
            y = 0;
            System.out.println(&quot;不存在x&quot;);
        &#125;

        System.out.println(&quot;y&quot;+y);

</code></pre>
</blockquote>
<p><strong>键盘录入案例比较</strong></p>
<pre><code class="java">    // 键盘录入判断最大值

        Scanner sc = new Scanner(System.in);

        System.out.println(&quot;1:&quot;);
        int a = sc.nextInt();

        System.out.println(&quot;2: &quot;);
        int b = sc.nextInt();

        // 常规比较
        if (a &gt; b) &#123;
            System.out.println(&quot;最大值是：&quot;+a);
        &#125;else &#123;
            System.out.println(&quot;最大值是：&quot;+b);
        &#125;


        // 用一个变量值接受


        int max;
        if (a &gt; b) &#123;
            max = a;
            System.out.println(&quot;max：&quot;+max);
        &#125;else &#123;
            max = b;
            System.out.println(&quot;max：&quot;+max);
        &#125;

        // 对变量max 做操作

        max = max + 100;
        System.out.println(max);</code></pre>
<h3 id="1-2-7、选择结构语句"><a href="#1-2-7、选择结构语句" class="headerlink" title="1.2.7、选择结构语句"></a>1.2.7、选择结构语句</h3><p><strong>switch</strong></p>
<pre><code class="java">package myOperator;

import java.util.Scanner;

/**
 * Created by JackFeng on 2020/2/26.
 */


/*
* switch语句格式：
*       switch (表达式)&#123;
*           case 值1：
*               语句体1;
*           case 值2：
*               语句体2;
*           ...
*           default:
*               语句体n+1;
*               break;
*
* &#125;
*
*
*
* */

public class SwitchDemo &#123;
    public static void main(String[] args) &#123;

        /*
        * 格式解释：
        *   表达式： byte，short，int，char
        *         jdk5 以后 可以是枚举
        *         jdk7 以后 可以是字符串
        *   case后边的值：就是用来和表达式的值进行匹配的内容
        *   break：表示中断的意思
        *   default： 所有值都不匹配的时候（相当于else）
        *
        * */


        // 键盘录入 1-7 判断星期几

        Scanner sc = new Scanner(System.in);

        // 接受数据
        System.out.println(&quot;请输入数字 1-7:&quot;);
        int weekday = sc.nextInt();

        switch (weekday)&#123;
            case 1:
                System.out.println(&quot;星期一&quot;);
                break;
            case 2:
                System.out.println(&quot;星期二&quot;);
                break;
            case 3:
                System.out.println(&quot;星期三&quot;);
                break;
            case 4:

                System.out.println(&quot;星期四&quot;);
                break;
            case 5:
                System.out.println(&quot;星期五&quot;);
                break;
            case 6:
                System.out.println(&quot;星期六&quot;);
                break;
            case 7:
                System.out.println(&quot;星期天&quot;);
                break;
            default:
                System.out.println(&quot;你输入的数据有误&quot;);
                break;
        &#125;

    &#125;

&#125;
</code></pre>
<h3 id="1-2-8、循环结构语句"><a href="#1-2-8、循环结构语句" class="headerlink" title="1.2.8、循环结构语句"></a>1.2.8、循环结构语句</h3><h4 id="1-2-8-1、for"><a href="#1-2-8-1、for" class="headerlink" title="1.2.8.1、for"></a>1.2.8.1、for</h4><pre><code class="java">package myOperator;

/**
 * Created by JackFeng on 2020/2/26.
 */

/*
* for循环语句的格式：
*   for(初始化语句;判断条件语句;控制条件语句）&#123;
*       循环体语句：
*
* &#125;
*
* */

public class ForDemo &#123;

    public static void main(String[] args) &#123;

//        输出10次 hello
        for (int i=1;i&lt;=10;i++)&#123;
            System.out.println(&quot;hello&quot;+i);
        &#125;

        // 获取 1-5
        for (int x =1 ;x &lt;=5;x++)&#123;
            System.out.println(&quot;-----&quot;);
            System.out.println(x);
        &#125;

        // 获取 5-1
        for (int x = 5; x &gt;= 1; x--) &#123;
            System.out.println(&quot;======&quot;);
            System.out.println(x);
        &#125;

        // 1-5 求和

        //初始化值为0

        int sum = 0;
        for (int x =1;x&lt;=5;x++)&#123;
            sum = sum + x;
//            sum += x;
            System.out.println(&quot;累加值为:&quot;+sum);

        &#125;
        System.out.println(&quot;sum&quot;+sum);

    &#125;
&#125;


</code></pre>
<p><strong>1-100 偶数和</strong></p>
<pre><code class="java">        // 结果：2550
        int s = 0;
        for (int x =1;x&lt;=100;x++)&#123;
            if (x%2 ==0)&#123;
                s += x;
            &#125;
        &#125;
        System.out.println(&quot;1-100偶数求和为：&quot;+s);</code></pre>
<p><strong>水仙花</strong></p>
<pre><code class="java">        //经典案例 水仙花数
        // EG: 153
        // 个位： 153%10
        // 十位： 153/10%10
        // 百位： 153/10/10%10
        int count = 0;

        for (int x=100;x&lt;=999;x++)&#123;
            int gw =x % 10;
            int sw =x/10 % 10;
            int bw =x/10/10 % 10;
            if ((gw*gw*gw +sw*sw*sw + bw*bw*bw )==x)&#123;
                System.out.println(x);
                count++; //统计次数
            &#125;
        &#125;
        //输出统计值
        System.out.println(count);

</code></pre>
<h4 id="1-2-8-2、while"><a href="#1-2-8-2、while" class="headerlink" title="1.2.8.2、while"></a>1.2.8.2、while</h4><pre><code class="java">package myOperator;

/**
 * Created by JackFeng on 2020/2/26.
 */
public class WhileDemo &#123;

    public static void main(String[] args) &#123;

        // 输出10次 你好
        // for 实现

        for (int i =1;i&lt;=10;i++)&#123;
            System.out.println(&quot;你好&quot;);
        &#125;

        // while 实现

        int s = 1;
        while (s&lt;=10)&#123;
            System.out.println(&quot;Nihao&quot;);
            s++;
        &#125;


    &#125;

&#125;
</code></pre>
<h4 id="1-2-8-3、do…while"><a href="#1-2-8-3、do…while" class="headerlink" title="1.2.8.3、do…while"></a>1.2.8.3、do…while</h4><pre><code class="java">package myOperator;

/**
 * Created by JackFeng on 2020/2/26.
 */
public class DoWhileDemo &#123;

    public static void main(String[] args) &#123;
        // 输出10次 HI

        for (int i =1;i&lt;=10;i++)&#123;
            System.out.println(&quot;Hi&quot;);
        &#125;

        // do while 改写

        int x = 1;
        do &#123;
            // 循环体语句
            System.out.println(&quot;HI hi&quot;);
            // 控制条件语句
            x++;
        &#125;
        // 判断体语句
        while (x &lt;= 10);



    &#125;

&#125;
</code></pre>
<h4 id="1-2-8-4、-三种循环语句区别"><a href="#1-2-8-4、-三种循环语句区别" class="headerlink" title="1.2.8.4、 三种循环语句区别"></a>1.2.8.4、 三种循环语句区别</h4><blockquote>
<p>A: do…while  循环至少执行一次循环体</p>
<p>B: for和 while  必须判断条件成立才执行循环体</p>
</blockquote>
<pre><code class="java">package myOperator;

/**
 * Created by JackFeng on 2020/2/26.
 */
public class XunDemo &#123;

    public static void main(String[] args) &#123;

        int x = 3;
        while(x &lt;3)&#123;
            System.out.println(&quot;while 循环体&quot;);
            x++;
        &#125;


        int y = 3;
        do &#123;
            System.out.println(&quot; do while 循环ti &quot;);
            y++;
        &#125; while (y &lt; 3);
    &#125;
&#125;
</code></pre>
<p><strong>for 和 while 区别</strong></p>
<blockquote>
<p>for循环结束后，初始化变量不可被使用。</p>
<p>while 循环结束后，初始化变量可以被使用。</p>
<p>推荐使用顺序：</p>
<ul>
<li>for</li>
<li>while</li>
<li>do…while</li>
</ul>
</blockquote>
<pre><code class="java">    // for 和 while 的区别

    public static void main(String[] args) &#123;

        //for
        for (int i = 0; i &lt;5 ; i++) &#123;
            System.out.println(&quot;这里是for循环&quot;);
        &#125;
//        System.out.println(&quot;i:&quot;+i); 这里是调用不了的

        //while

        int x =0;
        while (x&lt;5)&#123;
            System.out.println(&quot;while循环&quot;);
            x++;
        &#125;
        System.out.println(&quot;x:&quot;+x);


    &#125;
</code></pre>
<h3 id="1-2-9、跳转控制语句"><a href="#1-2-9、跳转控制语句" class="headerlink" title="1.2.9、跳转控制语句"></a>1.2.9、跳转控制语句</h3><p><strong>Break</strong>（中断）</p>
<blockquote>
<p>break：中断</p>
<p>使用场景：</p>
<ul>
<li>A：switch语句中</li>
<li>B：循环中</li>
</ul>
<p>注意：</p>
<ul>
<li>离开场景，将无意义。</li>
</ul>
<p>作用：</p>
<ul>
<li>用于结束循环</li>
</ul>
</blockquote>
<pre><code class="java">package com.data.it;

/**
 * Created by JackFeng on 2020/3/1.
 */
public class BreakDemo &#123;

    public static void main(String[] args) &#123;

        for (int i = 0; i &lt;4 ; i++) &#123;
            System.out.println(&quot;这是个正常的循环&quot;);

        &#125;

        System.out.println(&quot;============&quot;);
        for (int i = 0; i &lt;4 ; i++) &#123;

            if (i==1)&#123;
                break;
            &#125;
            System.out.println(&quot;这是加入break控制的循环&quot;);
        &#125;

    &#125;
&#125;

</code></pre>
<p><strong>Continue</strong>（继续）</p>
<blockquote>
<p>continue：继续</p>
<p>使用场景：</p>
<ul>
<li>循环中</li>
</ul>
<p>作用：</p>
<ul>
<li>结束一次循环，进入下一次循环。</li>
</ul>
</blockquote>
<pre><code class="java">package com.data.it;

import java.sql.SQLOutput;

/**
 * Created by JackFeng on 2020/3/1.
 */
public class BreakAndContinueDemo &#123;
    public static void main(String[] args) &#123;

        for (int i = 0; i &lt;=10 ; i++) &#123;

//            break:结束整个循环

            if (i == 2)&#123;
                break;
            &#125;
            System.out.println(&quot;B And C&quot;);

//            continue 结束本次循环，继续下一次循环
            if (i==3)&#123;
                continue;
            &#125;
            System.out.println(&quot;C === A&quot;);

        &#125;
    &#125;
&#125;

</code></pre>
<h2 id="1-3、Random"><a href="#1-3、Random" class="headerlink" title="1.3、Random"></a>1.3、Random</h2><blockquote>
<p>Random：用于产生随机数</p>
<p>使用步骤：</p>
<ul>
<li>A：导包<ul>
<li>import java.util.Random;</li>
</ul>
</li>
<li>B：创建对象<ul>
<li>Random r = new Random();</li>
</ul>
</li>
<li>C：获取随机数<ul>
<li>int number = r.nextInt(10)</li>
<li>数据范围：[0,10) 包括0，但不包括10</li>
</ul>
</li>
</ul>
</blockquote>
<pre><code class="java">package com.data.it;


import java.util.Random;

/**
 * Created by JackFeng on 2020/3/1.
 */
public class RandomDemo &#123;

    public static void main(String[] args) &#123;
        //创建对象
        Random r = new Random();

        // 获取随机数
        int n = r.nextInt(10);

        System.out.println(&quot;n:&quot;+n);

        for (int i = 0; i &lt;10 ; i++) &#123;
            int num = r.nextInt(10);

            System.out.println(&quot;第&quot;+i+&quot;次随机数结果为：&quot;+num);

        &#125;


        // 如何获取100 - 1之间的随机数

        int ii = r.nextInt(100);// [0,99]
        int T = r.nextInt(100)+1;// +1 即可


    &#125;


&#125;


</code></pre>
<p><strong>猜数字游戏</strong></p>
<pre><code class="java">package com.data.it;

import java.util.Random;
import java.util.Scanner;

/**
 * Created by JackFeng on 2020/3/1.
 */

/*
* 猜数字游戏：
*       系统产生一个 1-100 的数字，猜出这个数字是多少
*
* 分析：
*   A：系统产生一个1-100之间的随机数
*       Random r = new Random();
*       int number = r.nextInt(100)+1;
*   B: 键盘录入要猜的数据
*   C: 比较这两个数据的大小
*       大了：提示大了
*       小了：提示小了
*       相等：猜中了
*   D：多次猜数据，而我们不知道猜多少次？
*       while(true)&#123;循环体语句&#125;;
*
*
* */


public class RandomNumDemo &#123;
    public static void main(String[] args) &#123;


//      产生1-100随机数
        Random r = new Random();
//        获取随机数
        int i = r.nextInt(100)+1;



//        判断是否猜中 多次猜数据
        // 录入的数据 要放在判断里 否则永远也猜不中
        while (true) &#123;

            //        键盘录入
            Scanner s = new Scanner(System.in);

//        获取输入数据
            System.out.println(&quot;请输入你要猜的数据：&quot;);
            int g = s.nextInt();

            if (g&gt;i)&#123;
                System.out.println(&quot;你猜的&quot;+g+&quot;大了&quot;);
            &#125;else  if (g&lt;i)&#123;
                System.out.println(&quot;你猜的&quot;+g+&quot;小了&quot;);
            &#125;else &#123;
                System.out.println(&quot;恭喜你猜中了&quot;);
                break;
            &#125;
        &#125;



    &#125;
&#125;

</code></pre>
<h2 id="1-4、数组"><a href="#1-4、数组" class="headerlink" title="1.4、数组"></a>1.4、数组</h2><blockquote>
<p>数组：存储同一种数据类型的多个元素的容器</p>
<p>取值：</p>
<ul>
<li>数组名 【索引】</li>
</ul>
<p>定义格式：</p>
<ul>
<li>A：数据类型[] 数组名；(推荐方式)</li>
<li>B：数据类型 数组名[];</li>
<li>案例：<ul>
<li>int[] arr; 定义int类型的数组，名称为 arr</li>
<li>int arr[]；定义int类型的变量，变量名为arr数组</li>
</ul>
</li>
</ul>
<p>数组初始化：</p>
<ul>
<li>A：数组开辟内存空间，为数组中的每个元素赋值</li>
<li>B：数组初始的方式：<ul>
<li>a：动态初始化    只给出长度，系统给初始化值</li>
<li>b：静态初始化    给出初始值，由系统决定长度</li>
</ul>
</li>
</ul>
<p>动态初始化：</p>
<ul>
<li>数据类型[] 数组名 = new 数据类型[数组长度];</li>
</ul>
<p>静态初始化：</p>
<ul>
<li>数据类型[] 数组名 = new 数据类型[]{元素1,元素2….};</li>
<li>简化格式：<ul>
<li>数据类型[] 数组名  ={元素1，元素2,…}</li>
</ul>
</li>
</ul>
</blockquote>
<p><strong>动态初始化</strong></p>
<pre><code class="java">package com.data.it;

/**
 * Created by JackFeng on 2020/3/1.
 */



public class MyArrayDemo &#123;

    public static void main(String[] args) &#123;
        //数据类型[] 数组名 = new 数据类型[数组长度];
        int[] arr = new int[3];

        // 释义
        /*
        * 左边：
        *   int：说明数组中的元素类型是 int 类型
        *   []:  说明是个数组
        *   arr： 数组名称
        *
        * 右边：
        *   new ： 为数组申请内存分配空间
        *   int： 数组中的元素是int类型
        *   []： 数组
        *   3： 数组的长度----数组中元素的个数
        * */

        //输出数组名
        System.out.println(&quot;arr&quot;+arr); //[I@4554617c

        // 获取的是地址值，如何获取数组中的元素值
        // 数组中的元素都是有编号的，从0 开始，最大编号是 数组的长度-1
        // 索引 arr[0]
        // 取值：  数组名 配合 元素编号
        // 访问格式：数组名[索引]

        System.out.println(arr[0]);  //0
        System.out.println(arr[1]); // 0
        System.out.println(arr[2]);  //0

//        赋值
        arr[0] = 100;
        arr[2] = 200;

        System.out.println(&quot;=====&quot;);

        System.out.println(arr); // 001

        System.out.println(arr[0]); //100
        System.out.println(arr[1]); // 0
        System.out.println(arr[2]); //200


        // 指向一个数组

//         arr1 数组
        int[] arr1 = new int[3];
        System.out.println(arr1);
        System.out.println(arr1[0]);
        System.out.println(arr1[1]);
        System.out.println(arr1[2]);


        int[] arr2 = arr1;
        arr1[0] =111;
        arr1[1] =222;
        arr1[2] =123;

        System.out.println(&quot;=============&quot;);

        System.out.println(arr1);
        System.out.println(arr1[0]);
        System.out.println(arr1[1]);
        System.out.println(arr1[2]);


        System.out.println(arr2);
        System.out.println(arr2[0]);
        System.out.println(arr2[1]);
        System.out.println(arr2[2]);




    &#125;
&#125;

</code></pre>
<p><strong>静态初始化</strong></p>
<pre><code class="java">package com.data.it;

/**
 * Created by JackFeng on 2020/3/1.
 */


public class ArraryDemo &#123;

    public static void main(String[] args) &#123;

        int[] arr = new int[]&#123;1,2,3&#125;;

        int[] arr1 = &#123;1, 2, 3&#125;;

        System.out.println(arr);
        System.out.println(arr[0]);
        System.out.println(arr[1]);
        System.out.println(arr[2]);


//
        System.out.println(&quot;----------&quot;);
        System.out.println(arr1);
        System.out.println(arr1[0]);
        System.out.println(arr1[1]);
        System.out.println(arr1[2]);


    &#125;
&#125;
</code></pre>
<p><strong>常见小问题</strong></p>
<blockquote>
<p>小问题：</p>
<ul>
<li>ArrayIndexOutOfBoundsException: <em>数组索引越界异常</em><ul>
<li><strong>原因</strong> 我们访问了不存在的索引</li>
</ul>
</li>
<li>NullPointerException：空指针异常<ul>
<li><strong>原因</strong> 数组已经不在指向堆内存的数据了，还使用数组名去访问数组中的数据</li>
</ul>
</li>
</ul>
</blockquote>
<p><strong>数组遍历练习</strong></p>
<pre><code class="java">package com.data.it;

/**
 * Created by JackFeng on 2020/3/1.
 */
public class ArrayTest &#123;
    public static void main(String[] args) &#123;
        // 定义数组
        int[] arr = &#123;1, 2, 3, 4, 5, 6&#125;;

        // 通过for循环遍历输出 ,调用 数组属性:length 
        // 格式： 数组名.length

        for (int i = 0; i &lt;arr.length ; i++) &#123;
            System.out.println(arr[i]);
        &#125;


    &#125;
&#125;
</code></pre>
<p><strong>取最值</strong></p>
<blockquote>
<p>思路：</p>
<ul>
<li>A：先拿数组中的一个元素做参照物</li>
<li>B：遍历数组，让后边所有元素依次和参照物进行比较，如果元素比参照物大，就留下</li>
<li>C：整个循环遍历比较，留下的就是最大值</li>
</ul>
</blockquote>
<pre><code class="java">package com.data.it;

/**
 * Created by JackFeng on 2020/3/1.
 */
public class ArrayTest1 &#123;

    public static void main(String[] args) &#123;
        // 取最大值
        int[] arr = &#123;1, 2, 3, 55, 22, 10&#125;;

        // 定义一个参照值
        int max = arr[0];

        // 循环遍历整个数组

        for (int i = 1; i &lt;arr.length ; i++) &#123;
            if (arr[i]&gt;max)&#123;
                max = arr[i];
            &#125;
        &#125;
        System.out.println(&quot;最大值为：&quot;+max);


    &#125;
&#125;

</code></pre>
<h3 id="二维数组"><a href="#二维数组" class="headerlink" title="二维数组"></a>二维数组</h3><pre><code class="javascript">
二维数组： 元素为一堆数组的数组



定义格式：

- A：数据类型[ ] [ ] 数组名; (推荐的方式)
- B：数据类型 数组名[ ] [ ]
- C：数据类型[ ] 数组名[ ]

初始化：

- A： 动态初始化
  - 数据类型[ ] [ ] 数组名 = new 数据类型[m] [n];
  - m 表示的是 二维数组中一维数组的个数
  - n  表示的是 一维数组中的元素个数
- B： 静态初始化
  - 数据类型[ ] [ ] 数组名 = new 数据类型[ ] [ ] &#123;&#123;元素…&#125;,&#123;元素….&#125;&#125;
  - 简化格式：
    - 数据类型[ ] [ ] 数组名 = &#123;&#123;1,…&#125;,&#123;2….&#125;,&#123;3….&#125;&#125;

取值：

- *二维数组名配合索引可以获取到每一个一维数组*  【**arr[索引]**】
- *一维数组配合索引名可以获取到数组中的元素*【**arr[索引] [索引]**】

</code></pre>
<p><strong>二维数组取值</strong></p>
<pre><code class="java">package com.data.it;

/**
 * Created by JackFeng on 2020/3/1.
 */
public class Array2Test &#123;
    public static void main(String[] args) &#123;

        //数据类型[] [] 数组名 = &#123;&#123;元素..&#125;,&#123;元素...&#125;&#125;


        int[][] arr = &#123;&#123;1, 2, 3&#125;, &#123;1, 3, 6&#125;, &#123;2, 3, 6&#125;&#125;;
        //
//        System.out.println(arr);
//        System.out.println(arr[0]);
//        System.out.println(arr[0][0]);

        // 遍历二维数组

        // 第一个数组的元素
        for (int i = 0; i &lt;arr[0].length ; i++) &#123;

            System.out.println(arr[0][i]);

        &#125;

        System.out.println(&quot;==========&quot;);
        // 第二个数组的元素
        for (int i = 0; i &lt;arr[2].length ; i++) &#123;

            System.out.println(arr[0][i]);

        &#125;


        // 优化循环二维数组

        System.out.println(&quot; -----------&quot;);
        // 二维数组 arr.length 就是有几个 一维数组
        for (int i = 0; i &lt; arr.length ; i++) &#123;
            for (int j = 0; j &lt;arr[i].length ; j++) &#123;
                System.out.print(arr[i][j] + &quot;  &quot;);
            &#125;
            System.out.println(&quot;====&quot;);

        &#125;
    &#125;
&#125;
</code></pre>
<h2 id="1-5、函数"><a href="#1-5、函数" class="headerlink" title="1.5、函数"></a>1.5、函数</h2><h3 id="方法使用"><a href="#方法使用" class="headerlink" title="方法使用"></a>方法使用</h3><blockquote>
<p>方法： 特定功能的代码块</p>
<p>方法定义格式：</p>
<ul>
<li><p>修饰符 返回值类型 方法名(参数类型 参数名1，参数类型 参数名2 ..){</p>
<p>​    方法体;</p>
<p>​    return 返回值; </p>
<p>}</p>
</li>
</ul>
<p>格式解释：</p>
<ul>
<li>A：修饰符 public static</li>
<li>B：返回值类型 限定返回值的数据类型</li>
<li>C：方法名   方便我们调用方法的名字</li>
<li>D：参数类型 用于限定调用方法时传入数据的类型</li>
<li>E：参数名  用于接收调用方法时传入的数据变量</li>
<li>F： 方法体   完成功能代码</li>
<li>G：return  结束方法，并且把返回值带给调用者</li>
</ul>
<p>方法明确：</p>
<ul>
<li>A：返回值类型    明确功能结果的数据类型</li>
<li>B：参数列表     明确有几个参数，以及参数的数据类型</li>
</ul>
<p>方法调用：（有明确返回值的调用）</p>
<ul>
<li>A：单独调用 没有意义</li>
<li>B：输出调用，有意义，但是不够好(因为我想要拿结果进一步操作)</li>
<li>C：赋值调用</li>
</ul>
<p>方法调用：(void修饰的方法)</p>
<ul>
<li>如果一个方法没有明确的返回值，也不能空开返回值，用void表示该方法无返回值类型</li>
<li>只能输出调用。</li>
</ul>
</blockquote>
<p><strong>求和方法</strong></p>
<pre><code class="java">package com.data.it;

/**
 * Created by JackFeng on 2020/3/1.
 */
public class SumTest &#123;

    public static void main(String[] args) &#123;

        //调用sum
//        单独调用 无意义
//        sum(10, 20);

        // 输出调用，有意义，不完美
//        System.out.println(sum(10,20));


        // 赋值调用，常用操作。
        int i = sum(10, 20);
        System.out.println(i);
        System.out.println(i+1);

        // 对i 进行操作
        int j = sum(10,20)+10;
        System.out.println(j);



    &#125;
    /*
    * 两个明确：
    *       返回值：  int
    *       参数列表： int a , int b
    *
    *
    * */

    public static int sum(int a , int b )&#123;
        int c = a + b;
        return  c;
    &#125;

&#125;


</code></pre>
<p><strong>键盘录入两个数据判断是否相等</strong></p>
<pre><code class="java">package com.data.it;

import java.util.Scanner;

/**
 * Created by JackFeng on 2020/3/1.
 */
public class MethodTest &#123;
    public static void main(String[] args) &#123;

//        创建键盘录入
        Scanner sc = new Scanner(System.in);
//        接收数据
        System.out.println(&quot;请输入第一个数据：&quot;);
        int x = sc.nextInt();

        System.out.println(&quot;请输入第二个数据：&quot;);
        int y = sc.nextInt();

//        调用方法
        boolean b = bijiao(x, y);

        System.out.println(b);

    &#125;

    /*
    * 求两个值是否相等：
    *   返回值： boolean
    *   参数列表： int a,int b
    *
    * */


    public static  boolean bijiao(int a , int b )&#123;
        if (a==b)&#123;
            return true;
        &#125;else &#123;
            return false;
        &#125;
    &#125;

&#125;

</code></pre>
<p><strong>水仙花数</strong></p>
<pre><code class="java">package com.data.it;

/**
 * Created by JackFeng on 2020/3/1.
 */
public class MethodTest1 &#123;

    public static void main(String[] args) &#123;
        //调用方法
        printFlower();
    &#125;

    /*
    * 水仙花数打印到控制台方法
    *
    *  两个参数：
    *       返回值类型：void
    *       参数列表： 无参数
    *
    * */

    public  static  void printFlower()&#123;

        for (int i = 100; i &lt;1000 ; i++) &#123;
            int g = i%10;
            int s = i/10%10;
            int b = i/10/10%10;

            if (g*g*g + s*s*s + b*b*b == i)&#123;

                System.out.println(i);
            &#125;

        &#125;

    &#125;

&#125;

</code></pre>
<h3 id="方法重载"><a href="#方法重载" class="headerlink" title="方法重载"></a>方法重载</h3><blockquote>
<p>方法重载： 在同一个类中，出现了方法名相同</p>
<p><em>不能出现参数名以及参数条件一致的方法</em></p>
<p>特点：</p>
<ul>
<li>方法名相同，参数不同</li>
<li>参数不同<ul>
<li>参数数量不同</li>
<li>参数个数不同</li>
</ul>
</li>
</ul>
<p>注意：在调用方法的时候，java虚拟机会通过参数列表的不同来区分同名的方法。</p>
</blockquote>
<p><strong>比较两个数据是否相等</strong></p>
<pre><code class="java">package com.data.it;

/**
 * Created by JackFeng on 2020/3/1.
 */
public class MethodTest2 &#123;
    public static void main(String[] args) &#123;
        System.out.println(compare(10,10));
        System.out.println(compare(10L,10L));
        System.out.println(compare((byte) 10,(byte)20));
        System.out.println(compare((short) 10,(short) 20));
    &#125;

    //byte

    public static boolean compare(byte a , byte b)&#123;
        System.out.println(&quot;byte&quot;);
        return a == b;
    &#125;

    //short

    public static boolean compare(short a , short b)&#123;
        System.out.println(&quot;short&quot;);
        return a == b;
    &#125;

    //int

    public static boolean compare(int a , int b)&#123;
        System.out.println(&quot;int&quot;);
        return a == b;
    &#125;

    //long

    public static boolean compare(long a , long b)&#123;
        System.out.println(&quot;long&quot;);
        return a == b;
    &#125;



&#125;


</code></pre>
<h3 id="形式参数"><a href="#形式参数" class="headerlink" title="形式参数"></a>形式参数</h3><blockquote>
<p>如果方法的参数是基本数据类型：</p>
<p>​        形式参数的改变不影响实际参数</p>
<p>如果方法的参数是引用数据类型：</p>
<p>​        形式参数的改变直接影响实际参数</p>
</blockquote>
<p><strong>数组遍历</strong></p>
<pre><code class="java">package com.data.it;

/**
 * Created by JackFeng on 2020/3/1.
 */
public class ArrayDo &#123;
    public static void main(String[] args) &#123;

        int[] arr = &#123;1, 2, 3, 4, 5&#125;;
        System.out.println(&quot;第一种方式&quot;);
        printArray(arr);

        System.out.println(&quot;第二种方式&quot;);
        printArray1(arr);


    &#125;


    /*
    * 两个明确：
    *       返回类型： void
    *       参数列表： int[] arr
    * */

    public static void printArray(int[] arr)&#123;
        for (int i = 0; i &lt;arr.length ; i++) &#123;
            System.out.println(arr[i]);
        &#125;
    &#125;
    public static void printArray1(int[] arr)&#123;

        // 输出为这样的 [1,2,3,4,5]
        System.out.print(&quot;[&quot;);
        for (int i = 0; i &lt;arr.length ; i++) &#123;
            if (i==arr.length-1)&#123;
                System.out.println(arr[i]+&quot;]&quot;);
            &#125;else &#123;
                System.out.print(arr[i]+&quot;, &quot;);
            &#125;
        &#125;
    &#125;


&#125;

</code></pre>
<h2 id="1-6、断点调试"><a href="#1-6、断点调试" class="headerlink" title="1.6、断点调试"></a>1.6、断点调试</h2><blockquote>
<p>断点调试的作用：</p>
<p>​    A： 查看程序的执行流程</p>
<p>​    B： 调试程序</p>
<p>断点：</p>
<p>​    – 标记</p>
<p><em>哪里需要点哪里</em> 需加在有效的地方</p>
</blockquote>
<h2 id="1-7、基础练习"><a href="#1-7、基础练习" class="headerlink" title="1.7、基础练习"></a>1.7、基础练习</h2><p><strong>不死神兔计算</strong></p>
<pre><code class="java">package myTest;

/**
 * Created by JackFeng on 2020/3/1.
 */
public class Test &#123;
    public static void main(String[] args) &#123;
        // 20个月 兔子的对数
        // 1,1,2,3,5....

//        定义数组
        int[] arr = new int[20];

        // 给数组赋值
        arr[0] = 1;
        arr[1] = 1;

        // 找规律赋值
        for (int i = 2; i &lt;arr.length ; i++) &#123;
            arr[i] = arr[i - 1] + arr[i - 2];
        &#125;
        //输出结果
        System.out.println(&quot;第20个月兔子的对数是：&quot;+arr[19]);

    &#125;
&#125;
</code></pre>
<p><strong>评委评分</strong></p>
<blockquote>
<p>需求：</p>
<p>​    在编程竞赛中，有6个评委为参赛选手打分，分数为0-100的整数分。</p>
<p>​    选手最后的得分为，去掉一个最高分与最低分，剩下4个评委的平均值</p>
<p>分析：</p>
<ul>
<li>A：定义一个长度为6的数组</li>
<li>B：键盘录入评委的分数</li>
<li>C：写方法实现最高分、最低分</li>
<li>D：写方法求评委分数和</li>
<li>E：平均分：（和-最高分-最低分）/（arr.length-2）</li>
<li>F：输出平均分</li>
</ul>
</blockquote>
<pre><code class="java">package myTest;

import java.util.Scanner;

/**
 * Created by JackFeng on 2020/3/2.
 */
public class Test1 &#123;
    public static void main(String[] args) &#123;


        //定义数组
        int[] arr = new int[6];

        //键盘录入

        Scanner sc = new Scanner(System.in);

        //键盘录入评委分数

        for (int i = 0; i &lt;arr.length ; i++) &#123;

            //接受数据
            System.out.println(&quot;请输入第 &quot;+(i+1)+&quot;个评委给出的分数&quot;);
            int score = sc.nextInt();
            arr[i] = score;
        &#125;

        //调用方法
        int max = getMax(arr);
        int min = getMin(arr);

        int sum = sum(arr);

        // 求平均分
        int avg = (sum - max - min) / (arr.length - 2);

        System.out.println(&quot;该选手的最终得分是：&quot;+avg);



    &#125;


    //最高分
    /*
    * 两个明确：
    *      返回值类型： int
    *       参数列表： int [] arr
    *
    *
    * */
    public static  int getMax(int[] arr)&#123;
        //定义参照物
        int max = arr[0];

        for (int i = 1; i &lt;arr.length ; i++) &#123;
            if (arr[i]&gt;max)&#123;
                max = arr[i];
            &#125;

        &#125;
        return max;
    &#125;


    // 最低分
    public static  int getMin(int[] arr)&#123;
        //定义参照物
        int min = arr[0];

        for (int i = 1; i &lt;arr.length ; i++) &#123;
            if (arr[i]&lt;min)&#123;
                min = arr[i];
            &#125;

        &#125;
        return min;
    &#125;

    // 求和
    public static  int sum(int[] arr)&#123;
        // 定义求和变量
        int sum = 0;
        for (int i = 0; i &lt;arr.length ; i++) &#123;
            sum += arr[i];
        &#125;
        return sum;
    &#125;


&#125;

</code></pre>
<p><strong>键入数组反转</strong></p>
<blockquote>
<p>需求：</p>
<ul>
<li>1、键盘录入5个int的数据存在arr中</li>
<li>2、定义方法将arr数组中的内容反转</li>
<li>3、定义方法对反转后的数组进行遍历</li>
</ul>
</blockquote>
<pre><code class="java">package myTest;

import java.util.Scanner;

/**
 * Created by JackFeng on 2020/3/2.
 */


public class Test2 &#123;
    public static void main(String[] args) &#123;


        int[] arr = new int[5];

        Scanner sc = new Scanner(System.in);

        for (int i = 0; i &lt;arr.length ; i++) &#123;
            System.out.println(&quot;请输入&quot;+(i+1)+&quot;个元素值：&quot;);
            int number = sc.nextInt();
            arr[i] = number;
        &#125;

        printArray(arr);


        // 反转 arr
        reverse(arr);
        System.out.println(&quot;反转后&quot;);
        printArray(arr);

    &#125;

    //遍历数组

    public  static void printArray(int[] arr)&#123;

        System.out.print(&quot;[&quot;);
        for (int i = 0; i &lt;arr.length ; i++) &#123;

            if (i==arr.length-1)&#123;
                System.out.println(arr[i]+&quot;]&quot;);
            &#125;else&#123;
                System.out.print(arr[i]+&quot;, &quot;);
            &#125;

        &#125;


    &#125;

    // 反转数组
    public  static  void  reverse(int[] arr)&#123;
        for(int start =0, end= arr.length-1; start&lt;=end;start++,end--)&#123;
            int temp = arr[start];
            arr[start] = arr[end];
            arr[end] = temp;

        &#125;
    &#125;

&#125;

</code></pre>

  
  
    
    <div class='footer'>
      
      
        
  <div class="related_posts">
    <section class='header'>
      <i class="fas fa-bookmark fa-fw" aria-hidden="true"></i><span>相关文章</span>
    </section>
    <section class='body'>
      <div class="vlts-rps"><a class="item" href="\posts\2834.html" title="Java 常用API-II" rel="bookmark "><img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-wallpaper-minimalist/2020/046.jpg" /><span class="title">Java 常用API-II</span><span class="excerpt">JavaAPP-II</span></a><a class="item" href="\posts\17415.html" title="Java环境" rel="bookmark "><img src="https://gitee.com/DataITems/cdn/raw/master/20200508000334.png" /><span class="title">Java环境</span><span class="excerpt">Java JDK 环境安装</span></a><a class="item" href="\posts\8589.html" title="Java面向对象(封装)" rel="bookmark "><img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-wallpaper-minimalist/2020/046.jpg" /><span class="title">Java面向对象(封装)</span><span class="excerpt">Java面向对象 封装！</span></a><a class="item" href="\posts\32274.html" title="Java常用API" rel="bookmark "><img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-wallpaper-minimalist/2020/046.jpg" /><span class="title">Java常用API</span><span class="excerpt">Java常用API-I</span></a><a class="item" href="\posts\43249.html" title="Java面向对象 (继承、多态)" rel="bookmark "><img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-wallpaper-minimalist/2020/046.jpg" /><span class="title">Java面向对象 (继承、多态)</span><span class="excerpt">Java面向对象 继承 多态</span></a></div></section></div>
      
      
        <div class='copyright'>
          <blockquote>
            
              
                <p>版权声明：本网站所有文章除特别声明外，均采用 <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="/">数据科学</a></p>

              
            
              
                <p>本文永久链接是：<a href=http://www.a2data.cn/posts/34708.html>http://www.a2data.cn/posts/34708.html</a></p>
              
            
          </blockquote>
        </div>
      
      
        <div class='donate'>
          <div class='imgs'>
            
              <img src='https://gitee.com/DataITems/cdn/raw/master/alipay.jpg'>
            
              <img src='https://gitee.com/DataITems/cdn/raw/master/wechat.png'>
            
          </div>
        </div>
      
    </div>
  
  
    


  <div class='article-meta' id="bottom">
    <div class='new-meta-box'>
      
        
          <div class="new-meta-item date" itemprop="dateUpdated" datetime="2020-09-18T10:25:47+08:00">
  <a class='notlink'>
    <i class="fas fa-edit fa-fw" aria-hidden="true"></i>
    <p>更新于：Sep 18, 2020</p>
  </a>
</div>

        
      
        
          
  
  <div class="new-meta-item meta-tags"><a class="tag" href="/tags/Java/" rel="nofollow"><i class="fas fa-hashtag fa-fw" aria-hidden="true"></i><p>Java</p></a></div>


        
      
        
      
        
          
  <div class="new-meta-item wordcount">
    <a class='notlink'>
      <i class="fas fa-keyboard fa-fw" aria-hidden="true"></i>
      <p>8.6k words</p>
    </a>
  </div>
  <div class="new-meta-item readtime">
    <a class='notlink'>
      <i class="fas fa-hourglass-half fa-fw" aria-hidden="true"></i>
      <p>40 min</p>
    </a>
  </div>


        
      
        
          
  <div class="new-meta-item share -mob-share-list">
  <div class="-mob-share-list share-body">
    
      
        <a class="-mob-share-qq" title="" rel="external nofollow noopener noreferrer noopener"
          
          target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://www.a2data.cn/posts/34708.html&title=Java基础语法 - DataScience&pics=https://gitee.com/DataITems/cdn/raw/master/20200508000334.png&summary=Java基础语法"
          
          >
          
            <img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/qq.png">
          
        </a>
      
    
      
        <a class="-mob-share-qzone" title="" rel="external nofollow noopener noreferrer noopener"
          
          target="_blank" href="https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=http://www.a2data.cn/posts/34708.html&title=Java基础语法 - DataScience&pics=https://gitee.com/DataITems/cdn/raw/master/20200508000334.png&summary=Java基础语法"
          
          >
          
            <img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/qzone.png">
          
        </a>
      
    
      
        <a class="-mob-share-weibo" title="" rel="external nofollow noopener noreferrer noopener"
          
          target="_blank" href="http://service.weibo.com/share/share.php?url=http://www.a2data.cn/posts/34708.html&title=Java基础语法 - DataScience&pics=https://gitee.com/DataITems/cdn/raw/master/20200508000334.png&summary=Java基础语法"
          
          >
          
            <img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/weibo.png">
          
        </a>
      
    
      
        
        <div class='hoverbox'>
          <a class='share'><img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/wechat.png"></a>
          <div class='target'>
            <img src="">
          </div>
        </div>
      
    
  </div>
</div>



        
      
    </div>
  </div>


  
  

  
    <div class="prev-next">
      
        <a class='prev' href='/posts/8589.html'>
          <p class='title'><i class="fas fa-chevron-left" aria-hidden="true"></i>Java面向对象(封装)</p>
          <p class='content'>Java面向对象 封装！



面向对象（封装）
面向对象思想：

面向对象是基于面向过程的编程思想。
面向过程：强调每一个功能的步骤
面向对象：强调的是对象，然后用对象去调用功能


特点
A...</p>
        </a>
      
      
        <a class='next' href='/posts/17415.html'>
          <p class='title'>Java环境<i class="fas fa-chevron-right" aria-hidden="true"></i></p>
          <p class='content'>Java JDK 环境安装


Java环境

程序编译和运行需要使用

javaJDK 下的bin目录

环境变量配置：

JAVA_HOME
—— jdk安装目录

Path环境
—— %J...</p>
        </a>
      
    </div>
  
</article>


  

  <article class="post white-box reveal shadow" id="comments">
    <p ct><i class='fas fa-comments'></i> 评论</p>
    
    <div id="valine_container" class="valine_thread">
  <i class="fas fa-cog fa-spin fa-fw fa-2x"></i>
</div>

  </article>






</div>
<aside class='l_side'>
  
  
    
    

<section class="widget grid shadow desktop mobile">
  
  <header>
    
      <i class="fas fa-map-signs fa-fw" aria-hidden="true"></i><span class='name'>导航</span>
    
  </header>


  <div class='content'>
    <div class="grid navigation fixed">
      
        <a class="flat-box" title="/categories/" href="/categories/"
          
          
          id="categories">
          
            <i class="fas fa-book fa-fw fa-fw" aria-hidden="true"></i>
          
          内容大纲
        </a>
      
        <a class="flat-box" title="/archives/" href="/archives/"
          
          
          id="archives">
          
            <i class="fas fa-archive fa-fw fa-fw" aria-hidden="true"></i>
          
          文章归档
        </a>
      
        <a class="flat-box" title="/tags/" href="/tags/"
          
          
          id="tags">
          
            <i class="fas fa-fire fa-fw fa-fw" aria-hidden="true"></i>
          
          热门标签
        </a>
      
        <a class="flat-box" title="/Creator-said/" href="/Creator-said/"
          
          
          id="Creator-said">
          
            <i class="fas fa-comment-dots fa-fw fa-fw" aria-hidden="true"></i>
          
          主创说
        </a>
      
        <a class="flat-box" title="/contact/" href="/contact/"
          
          
          id="contact">
          
            <i class="fas fa-comments fa-fw fa-fw" aria-hidden="true"></i>
          
          留言板
        </a>
      
        <a class="flat-box" title="/friends/" href="/friends/"
          
          
          id="friends">
          
            <i class="fas fa-users fa-fw fa-fw" aria-hidden="true"></i>
          
          友情链接
        </a>
      
        <a class="flat-box" title="/" href="/"
          
          
            target="_blank"
          
          id="home">
          
            <i class="fas fa-clock fa-fw fa-fw" aria-hidden="true"></i>
          
          近期文章
        </a>
      
        <a class="flat-box" title="/tools/" href="/tools/"
          
          
          id="tools">
          
            <i class="fas fa-info-circle fa-fw fa-fw" aria-hidden="true"></i>
          
          软件控
        </a>
      
        <a class="flat-box" title="https://travellings.now.sh/" href="https://travellings.now.sh/"
          
            rel="noopener external nofollow noreferrer"
          
          
            target="_blank"
          
          id="https:travellingsnowsh">
          
            <i class="fa fa-binoculars fa-fw" aria-hidden="true"></i>
          
          开往
        </a>
      
    </div>
  </div>
</section>

  

  
    
    



  <section class="widget toc-wrapper shadow desktop mobile" id="toc-div" >
    
  <header>
    
      <i class="fas fa-list fa-fw" aria-hidden="true"></i><span class='name'>本文目录</span>
    
  </header>


    <div class='content'>
        <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-1%E3%80%81Java%E5%85%A5%E9%97%A8"><span class="toc-text">1.1、Java入门</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1-0%E3%80%81%E6%B3%A8%E9%87%8A"><span class="toc-text">1.1.0、注释</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1-1%E3%80%81%E5%85%B3%E9%94%AE%E5%AD%97"><span class="toc-text">1.1.1、关键字</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1-2%E3%80%81%E5%B8%B8%E9%87%8F"><span class="toc-text">1.1.2、常量</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1-3%E3%80%81%E5%8F%98%E9%87%8F"><span class="toc-text">1.1.3、变量</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1-4%E3%80%81%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B"><span class="toc-text">1.1.4、数据类型</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%95%B4%E5%9E%8B%E5%8F%98%E9%87%8F"><span class="toc-text">整型变量</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%B5%AE%E7%82%B9%E5%9E%8B%E5%8F%98%E9%87%8F"><span class="toc-text">浮点型变量</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E5%80%BC%E5%B8%B8%E9%87%8F"><span class="toc-text">值常量</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1-5%E3%80%81-%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%AD%98%E5%82%A8%E5%8D%95%E5%85%83"><span class="toc-text">1.1.5、 计算机存储单元</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1-6%E3%80%81%E6%A0%87%E8%AF%86%E7%AC%A6"><span class="toc-text">1.1.6、标识符</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1-7%E3%80%81%E8%BF%90%E7%AE%97%E7%AC%A6%E4%BC%98%E5%85%88%E7%BA%A7"><span class="toc-text">1.1.7、运算符优先级</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#1-2%E3%80%81%E5%9F%BA%E6%9C%AC%E7%B1%BB%E5%9E%8B%E6%95%B0%E6%8D%AE%E8%BD%AC%E6%8D%A2"><span class="toc-text">1.2、基本类型数据转换</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-1%E3%80%81%E5%AE%9A%E4%B9%89%E5%8F%98%E9%87%8F"><span class="toc-text">1.2.1、定义变量</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-2%E3%80%81%E5%8F%98%E9%87%8F%E5%AE%9A%E4%B9%89%E7%9A%84%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9"><span class="toc-text">1.2.2、变量定义的注意事项</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-3%E3%80%81%E7%B1%BB%E5%9E%8B%E8%BD%AC%E5%8C%96"><span class="toc-text">1.2.3、类型转化</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-4%E3%80%81%E8%BF%90%E7%AE%97%E7%AC%A6"><span class="toc-text">1.2.4、运算符</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-2-4-1%E3%80%81%E8%BF%90%E7%AE%97%E7%AC%A6"><span class="toc-text">1.2.4.1、运算符</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-2-4-2%E3%80%81%E8%BF%90%E7%AE%97%E7%AC%A6%E5%88%86%E7%B1%BB"><span class="toc-text">1.2.4.2、运算符分类</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#1%E3%80%81%E7%AE%97%E6%9C%AF%E8%BF%90%E7%AE%97%E7%AC%A6"><span class="toc-text">1、算术运算符</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#2%E3%80%81%E8%B5%8B%E5%80%BC%E8%BF%90%E7%AE%97%E7%AC%A6"><span class="toc-text">2、赋值运算符</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#3%E3%80%81%E5%85%B3%E7%B3%BB%E8%BF%90%E7%AE%97%E7%AC%A6"><span class="toc-text">3、关系运算符</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#4%E3%80%81%E9%80%BB%E8%BE%91%E8%BF%90%E7%AE%97%E7%AC%A6"><span class="toc-text">4、逻辑运算符</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#5%E3%80%81%E4%B8%89%E5%85%83%E8%BF%90%E7%AE%97%E7%AC%A6"><span class="toc-text">5、三元运算符</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-5%E3%80%81%E9%94%AE%E7%9B%98%E5%BD%95%E5%85%A5"><span class="toc-text">1.2.5、键盘录入</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-6%E3%80%81%E6%B5%81%E7%A8%8B%E6%8E%A7%E5%88%B6%E8%AF%AD%E5%8F%A5"><span class="toc-text">1.2.6、流程控制语句</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-7%E3%80%81%E9%80%89%E6%8B%A9%E7%BB%93%E6%9E%84%E8%AF%AD%E5%8F%A5"><span class="toc-text">1.2.7、选择结构语句</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-8%E3%80%81%E5%BE%AA%E7%8E%AF%E7%BB%93%E6%9E%84%E8%AF%AD%E5%8F%A5"><span class="toc-text">1.2.8、循环结构语句</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-2-8-1%E3%80%81for"><span class="toc-text">1.2.8.1、for</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-2-8-2%E3%80%81while"><span class="toc-text">1.2.8.2、while</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-2-8-3%E3%80%81do%E2%80%A6while"><span class="toc-text">1.2.8.3、do…while</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-2-8-4%E3%80%81-%E4%B8%89%E7%A7%8D%E5%BE%AA%E7%8E%AF%E8%AF%AD%E5%8F%A5%E5%8C%BA%E5%88%AB"><span class="toc-text">1.2.8.4、 三种循环语句区别</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-9%E3%80%81%E8%B7%B3%E8%BD%AC%E6%8E%A7%E5%88%B6%E8%AF%AD%E5%8F%A5"><span class="toc-text">1.2.9、跳转控制语句</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#1-3%E3%80%81Random"><span class="toc-text">1.3、Random</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#1-4%E3%80%81%E6%95%B0%E7%BB%84"><span class="toc-text">1.4、数组</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BA%8C%E7%BB%B4%E6%95%B0%E7%BB%84"><span class="toc-text">二维数组</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#1-5%E3%80%81%E5%87%BD%E6%95%B0"><span class="toc-text">1.5、函数</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%B9%E6%B3%95%E4%BD%BF%E7%94%A8"><span class="toc-text">方法使用</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%B9%E6%B3%95%E9%87%8D%E8%BD%BD"><span class="toc-text">方法重载</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BD%A2%E5%BC%8F%E5%8F%82%E6%95%B0"><span class="toc-text">形式参数</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#1-6%E3%80%81%E6%96%AD%E7%82%B9%E8%B0%83%E8%AF%95"><span class="toc-text">1.6、断点调试</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#1-7%E3%80%81%E5%9F%BA%E7%A1%80%E7%BB%83%E4%B9%A0"><span class="toc-text">1.7、基础练习</span></a></li></ol>
    </div>
  </section>


  


</aside>



      </div>
      
    
    <footer class="footer clearfix">
        <br><br>
        
            
                <br>
                <div class="social-wrapper">
                    
                        
                            <a href="https://github.com/A2Data"
                               class="social fab fa-github flat-btn"
                               target="_blank"
                               rel="external nofollow noopener noreferrer">
                                
                            </a>
                        
                    
                        
                            <a href="https://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&amp;email=a2data@163.com"
                               class="social fas fa-envelope-open flat-btn"
                               target="_blank"
                               rel="external nofollow noopener noreferrer">
                                
                            </a>
                        
                    
                        
                            <a href="tencent://AddContact/?fromId=50&amp;fromSubId=1&amp;subcmd=all&amp;uin=66860619"
                               class="social fab fa-qq flat-btn"
                               target="_blank"
                               rel="external nofollow noopener noreferrer">
                                
                            </a>
                        
                    
                        
                            <a href="https://gitee.com/DataITems/cdn/raw/master/baeab3a662ef96c3403f558a0bb578c.jpg"
                               class="social fab fa-weixin flat-btn"
                               target="_blank"
                               rel="external nofollow noopener noreferrer">
                                
                            </a>
                        
                    
                        
                            <a href="https://me.csdn.net/weixin_47093227"
                               class="social fab fa-cuttlefish flat-btn"
                               target="_blank"
                               rel="external nofollow noopener noreferrer">
                                
                            </a>
                        
                    
                </div>
                <div>
<!--                    <span id="timeDate"></span>-->
                    <i class="fas fa-heartbeat" style="transform:scale(1.1);color:rgba(255,0,0,.9)"></i>
                    <span id="times"></span>
                    <i class="fas fa-heartbeat" style="transform:scale(1.1);color:rgba(255,0,0,.9)"></i>
                    <script>
                        var now = new Date();
                        function createtime() {
                            var grt= new Date("12/18/2018 00:00:00");  //在此处修改你的建站时间，格式：月/日/年 时:分:秒
                            now.setTime(now.getTime()+250);
                            days = (now - grt ) / 1000 / 60 / 60 / 24; dnum = Math.floor(days);
                            hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum); hnum = Math.floor(hours);
                            if(String(hnum).length ==1 ){hnum = "0" + hnum;} minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum);
                            mnum = Math.floor(minutes); if(String(mnum).length ==1 ){mnum = "0" + mnum;}
                            seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
                            snum = Math.round(seconds); if(String(snum).length ==1 ){snum = "0" + snum;}
                            // document.getElementById("timeDate").innerHTML = "本站已运行 "+dnum+" 天 ";
                            document.getElementById("times").innerHTML = "本站已运行 "+dnum+" 天 "+ hnum + " 小时 " + mnum + " 分 " + snum + " 秒";
                        }
                        setInterval("createtime()",250);
                    </script>
                </div>
                <div class="pure">
                    <script src="https://pv.sohu.com/cityjson?ie=utf-8"></script>
                    <script>
                        var getOSAndBrowser = function () {
                            var os = navigator.platform;
                            var userAgent = navigator.userAgent;
                            var info = "";
                            var tempArray = "";
                            if (os.indexOf("Win") > -1) {
                                if (userAgent.indexOf("Windows NT 5.0") > -1) {
                                    info += "Win2000"
                                } else if (userAgent.indexOf("Windows NT 5.1") > -1) {
                                    info += "WinXP"
                                } else if (userAgent.indexOf("Windows NT 5.2") > -1) {
                                    info += "Win2003"
                                }
                                else if (userAgent.indexOf("Windows NT 6.0") > -1) {
                                    info += "WindowsVista"
                                } else if (userAgent.indexOf("Windows NT 6.1") > -1 || userAgent.indexOf("Windows 7") > -1) {
                                    info += "Win7"
                                } else if (userAgent.indexOf("Windows NT 6.2") > -1 || userAgent.indexOf("Windows 8") > -1) {
                                    info += "Win8"
                                }
                                else if (userAgent.indexOf("Windows NT 6.3") > -1 || userAgent.indexOf("Windows 8.1") > -1) {
                                    info += "Win8.1"
                                } else if (userAgent.indexOf("Windows NT 10.0") > -1 || userAgent.indexOf("Windows 10") > -1) {
                                    info += "Win10"
                                } else {
                                    info += "Other"
                                }
                            } else if (os.indexOf("Mac") > -1) {
                                info += "Mac"
                            } else if (os.indexOf("X11") > -1) {
                                info += "Unix"
                            } else if (os.indexOf("Linux") > -1) {
                                info += "Linux"
                            } else { info += "Other" } info += "/";
                            var isOpera = userAgent.indexOf("Opera") > -1;
                            var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera;
                            var isEdge = userAgent.toLowerCase().indexOf("edge") > -1 && !isIE;
                            var isIE11 = (userAgent.toLowerCase().indexOf("trident") > -1 && userAgent.indexOf("rv") > -1);
                            if (/[Ff]irefox(\/\d+\.\d+)/.test(userAgent)) {
                                tempArray = /([Ff]irefox)\/(\d+\.\d+)/.exec(userAgent);
                                info += tempArray[1] + tempArray[2]
                            } else if (isIE) {
                                var version = "";
                                var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
                                reIE.test(userAgent);
                                var fIEVersion = parseFloat(RegExp["$1"]);
                                if (fIEVersion == 7) {
                                    version = "IE7"
                                } else if (fIEVersion == 8) {
                                    version = "IE8"
                                } else if (fIEVersion == 9) { version = "IE9" } else if (fIEVersion == 10) { version = "IE10" } else { version = "0" } info += version
                            } else if (isEdge) { info += "Edge" } else if (isIE11) { info += "IE11" } else if (/[Cc]hrome\/\d+/.test(userAgent)) { tempArray = /([Cc]hrome)\/(\d+)/.exec(userAgent); info += tempArray[1] + tempArray[2] } else if (/[Vv]ersion\/\d+\.\d+\.\d+(\.\d)* *[Ss]afari/.test(userAgent)) { tempArray = /[Vv]ersion\/(\d+\.\d+\.\d+)(\.\d)* *([Ss]afari)/.exec(userAgent); info += tempArray[3] + tempArray[1] } else if (/[Oo]pera.+[Vv]ersion\/\d+\.\d+/.test(userAgent)) { tempArray = /([Oo]pera).+[Vv]ersion\/(\d+)\.\d+/.exec(userAgent); info += tempArray[1] + tempArray[2] } else { info += "unknown" } return info
                        }; document.write("欢迎来自" + returnCitySN["cname"] + "的朋友"); document.write(",您的 IP 是:" + returnCitySN["cip"]); document.write(",您使用的是:" + getOSAndBrowser());
                    </script>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://hexo.io/" target="_blank" title="由 Hexo 强力驱动">
                        <span class="badge-subject">Powered</span><span class="badge-value bg-blue">Hexo</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="http://beian.miit.gov.cn" target="_blank" title="[sqlsq.cn@备案]">
                        <span class="badge-subject">京ICP</span><span class="github-badge .bg-lightgrey">备20010978号</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://github.com/" target="_blank" title="静态网页托管于 GitHub Pages 和 Gitee Pages">
                        <span class="badge-subject">Hosted</span><span class="badge-value bg-brightgreen">GitHub & Gitee</span></a>
                </div>
                <br>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://www.foreverblog.cn/blog/1579.html" target="_blank" title="[A2Data@十年之约]">
                        <span class="badge-subject">Forever Blog</span><span class="badge-value bg-lightgrey">十年之约</span></a>
                </div>

                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://www.a2data.cn/" target="_blank" title="DataScience提供内容创作">
                        <span class="badge-subject">Copyright © 2018-2020</span><span class="badge-value bg-blueviolet">A2Data</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://www.jsdelivr.com/" target="_blank" title="jsDelivr 提供 CDN 加速服务">
                        <span class="badge-subject">CDN</span><span class="badge-value bg-orange">jsDelivr</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank" title="本站点采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可">
                        <span class="badge-subject"><i class="fa fa-copyright"></i></span><span class="badge-value bg-lightgrey">BY-NC-SA 4.0</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://996.icu/" target="_blank" title="支持 996.ICU">
                        <span class="badge-subject">Link</span><span class="badge-value bg-red">996.ICU</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://md.openwrite.cn/" target="_blank" title="OpenWrite.cn 特约提供服务">
                        <span class="badge-subject">微信</span><span class="badge-value bg-orange">公众号编辑器</span></a>
                </div>
                <div class="github-badge">
                    <a style="color: #fff" rel="license" href="https://www.leileitalk.com/" target="_blank" title="类类有话说 ">
                        <span class="badge-subject">类类</span><span class="badge-value bg-red">有话说</span></a>
                </div>

            
        
    </footer>


<style>
  .github-badge {
    display:inline-block;
    border-radius:4px;
    text-shadow:none;
    font-size:13px;
    color:#fff;
    line-height:15px;
    background-color:#ABBAC3;
    margin-bottom:5px;
  }
  .github-badge .badge-subject {
    display:inline-block;
    background-color:#4D4D4D;
    padding:4px 4px 4px 6px;
    border-top-left-radius:4px;
    border-bottom-left-radius:4px;
  }
  .github-badge .badge-value {
    display:inline-block;
    padding:4px 6px 4px 4px;
    border-top-right-radius:4px;
    border-bottom-right-radius:4px;
  }
  .github-badge .bg-brightgreen {
    background-color:#4DC820 !important;
  }
  .github-badge .bg-orange {
    background-color:#FFA500 !important;
  }
  .github-badge .bg-yellow {
    background-color:#D8B024 !important;
  }
  .github-badge .bg-blueviolet {
    background-color:#8833D7 !important;
  }
  .github-badge .bg-pink {
    background-color:#F26BAE !important;
  }
  .github-badge .bg-red {
    background-color:#e05d44 !important;
  }
  .github-badge .bg-blue {
    background-color:#007EC6 !important;
  }
  .github-badge .bg-lightgrey {
    background-color:#9F9F9F !important;
  }
  .github-badge .bg-grey, .github-badge .bg-gray {
    background-color:#555 !important;
  }
  .github-badge .bg-lightgrey, .github-badge .bg-lightgray {
    background-color:#9f9f9f !important;
  }
</style>

      <a class="s-top fas fa-arrow-up fa-fw" href='javascript:void(0)'></a>
    </div>
  </div>
  <div>
    <!-- required -->

<script src="https://cdn.jsdelivr.net/npm/jquery@3.5/dist/jquery.min.js"></script>

<script>
  function pjax_fancybox() {
    $(".md").find("img").not('.inline').not('a img').each(function () { //渲染 fancybox
      var element = document.createElement("a"); // a 标签
      $(element).attr("class", "fancybox");
      $(element).attr("pjax-fancybox", "");  // 过滤 pjax
      $(element).attr("href", $(this).attr("src"));
      if ($(this).attr("data-original")) {
        $(element).attr("href", $(this).attr("data-original"));
      }
      $(element).attr("data-fancybox", "images");
      var caption = "";   // 描述信息
      if ($(this).attr('alt')) {  // 判断当前页面是否存在描述信息
        $(element).attr('data-caption', $(this).attr('alt'));
        caption = $(this).attr('alt');
      }
      var div = document.createElement("div");
      $(div).addClass("fancybox");
      $(this).wrap(div); // 最外层套 div ，其实主要作用还是 class 样式
      var span = document.createElement("span");
      $(span).addClass("image-caption");
      $(span).text(caption); // 加描述
      $(this).after(span);  // 再套一层描述
      // 背景层
      var bgDiv = document.createElement("div");
      $(bgDiv).addClass("bg");
      if ($(this).attr('bg')) {
        $(bgDiv).css('background', $(this).attr('bg'));
      }
      $(this).wrap(bgDiv); // 背景层
      $(this).wrap(element);  // 最后套 a 标签
    })
    $(".md").find("img").fancybox({
      selector: '[data-fancybox="images"]',
      hash: false,
      loop: false,
      closeClick: true,
      helpers: {
        overlay: {closeClick: true}
      },
      buttons: [
        "zoom",
        "close"
      ]
    });
  };
  function SCload_fancybox() {
    if($(".md").find("img").not('.inline').not('a img').length+$(".article-entry").find("img").length==0)return;
    loadCSS("https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css", document.getElementById("loadcss"));
    setTimeout(function() {
      loadScript('https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js', pjax_fancybox)
    }, 1);
  };
  $(function () {
    SCload_fancybox();
  });
</script>


<!-- internal -->



  
  
  <div id="rightmenu-wrapper">
    <ul class="list-v rightmenu" id="rightmenu-content">

      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' 
      
      
      
         onclick="menuCopy()"
              
      
         id="menu-copy-text"
      >
        <i class='fas fa-copy fa-fw'></i> 复制选中内容
      </a>
    </li>
  
        
      
        
          <li class='navigation'>
            <a class='nav icon-only fix-cursor-default' onclick='history.back()'><i class='fas fa-arrow-left fa-fw'></i></a>
            <a class='nav icon-only fix-cursor-default' onclick='history.forward()'><i class='fas fa-arrow-right fa-fw'></i></a>
            <a class='nav icon-only fix-cursor-default' onclick='window.location.reload()'><i class='fas fa-redo fa-fw'></i></a>
            <a class='nav icon-only fix-cursor-default' href='/'><i class='fas fa-home fa-fw'></i></a>
          </li>
        
      
        
          <hr>
        
      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' href=https://support.qq.com/products/176810/
      
      
      
      
         id="https:supportqqcomproducts176810"
              >
        <i class='fa fa-question fa-fw'></i> 吐槽墙
      </a>
    </li>
  
        
      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' href=/tools/
      
      
      
      
         id="tools"
              >
        <i class='fa-fw fa fa-bars fa-fw fa-fw'></i> 软件控
      </a>
    </li>
  
        
      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' href=https://gitee.com/DataITems/cdn/raw/master/sys.png
      
      
      
      
         id="https:giteecomDataITemscdnrawmastersyspng"
              >
        <i class='fa fa-fan fa-spin fa-fw'></i> 公众号
      </a>
    </li>
  
        
      
        
          <hr>
        
      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' href=/about/
      
      
      
      
         id="about"
              >
        <i class='fas fa-location-arrow fa-fw'></i> 如人饮水
      </a>
    </li>
  
        
      
        
          
    <li>
      <a class='vlts-menu fix-cursor-default' href=/Creator-said/
      
      
      
      
         id="Creator-said"
              >
        <i class='fa fa-globe fa-fw fa-fw'></i> 冷暖自知
      </a>
    </li>
  
        
      
        
          <hr>
        
      
        
          <li class='music name'>
            <p class='nav music-title fix-cursor-default'></p>
          </li>
          <li class='music ctrl'>
            <a class='nav icon-only backward' onclick='aplayerBackward()'><i class='fas fa-step-backward fa-fw'></i></a>
            <a class='nav icon-only toggle' onclick='aplayerToggle()'><i class='fas fa-play fa-fw'></i></a>
            <a class='nav icon-only forward' onclick='aplayerForward()'><i class='fas fa-step-forward fa-fw'></i></a>
          </li>
          <li class='music volume'>
            <a class='nav volume'>
              <div class="aplayer-volume-bar-wrap">
                <div class="aplayer-volume-bar fix-cursor-pointer">
                  <div class="aplayer-volume"></div>
                  <i class='left fas fa-volume-off fa-fw'></i>
                  <i class='right fas fa-volume-up fa-fw'></i>
                </div>
              </div>
            </a>
          </li>
        
      
    </ul>
  </div>
  <script>
    window.document.oncontextmenu = function (event) {
      if (event.ctrlKey || $(window).width() <= 500) {
        if (event.ctrlKey) return true;
        if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) return true;
      }
      setMenulocation();
      setMenuCopy();
      if (true == true) {
        try {
          checkAPlayer();
          updateTitle();
        } catch (error) {console.log(error);}
      }
      return false;
    };
    document.getElementById('rightmenu-wrapper').oncontextmenu  = function (event) {
      event.stopPropagation();  // 阻止右键上的右键
      return false;
    }
    document.querySelectorAll('img').forEach((item) => {  // IMG 放出菜单
      item.oncontextmenu  = function (event) {
        event.stopPropagation();
        return true;
      }
    })
    document.addEventListener("click", function (event) {
      hideMenu();
    });
    function hideMenu(  ) {
      document.getElementById('rightmenu-wrapper').style.display = 'none';
    }
    function setMenulocation() {
      var mymenu = document.getElementById('rightmenu-wrapper');
      var menuContent = document.getElementById('rightmenu-content');
      var mouseClientX = event.clientX;
      var mouseClientY = event.clientY;
      var menuWidth = menuContent.offsetWidth == 0 ? 160 : menuContent.offsetWidth;
      var menuHeight = menuContent.offsetHeight == 0 ? 340 : menuContent.offsetHeight;
      var screenWidth = document.documentElement.clientWidth || document.body.clientWidth;
      var screenHeight = document.documentElement.clientHeight || document.body.clientHeight;
      var showLeft = mouseClientX + menuWidth > screenWidth ? mouseClientX - menuWidth + 10 : mouseClientX;
      var showTop = mouseClientY + menuHeight > screenHeight ? mouseClientY - menuHeight + 10 : mouseClientY;
      mymenu.style.left = showLeft + "px";
      mymenu.style.top = showTop + "px";
      mymenu.style.display = 'block';
    }
    function setMenuCopy() {
      if (window.getSelection().toString()) {
        document.getElementById('menu-copy-text').style.display = 'block';
      } else {
        document.getElementById('menu-copy-text').style.display = 'none';
      }
    }
    function menuCopy() {
      document.execCommand("Copy");
      $.message({title:'复制成功',message: window.getSelection().toString(),type:'success'});
    }
  </script>





  
<script src="/js/issues.js" aysc></script>




  <script defer src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.1.0/dist/lazyload.min.js"></script>
<script>
  // https://www.npmjs.com/package/vanilla-lazyload
  // Set the options globally
  // to make LazyLoad self-initialize
  window.lazyLoadOptions = {
    elements_selector: ".lazyload",
    threshold: 0
  };
  // Listen to the initialization event
  // and get the instance of LazyLoad
  window.addEventListener(
    "LazyLoad::Initialized",
    function (event) {
      window.lazyLoadInstance = event.detail.instance;
    },
    false
  );
  document.addEventListener('DOMContentLoaded', function () {
    lazyLoadInstance.update();
  });
  document.addEventListener('pjax:complete', function () {
    lazyLoadInstance.update();
  });
</script>




  
  
    <script>
      window.FPConfig = {
        delay: 0,
        ignoreKeywords: [],
        maxRPS: 5,
        hoverDelay: 25
      };
    </script>
    <script defer src="https://cdn.jsdelivr.net/gh/gijo-varghese/flying-pages@2.1.2/flying-pages.min.js"></script>
  




  <script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
    var clipboard = new ClipboardJS('.btn-copy', {
        target: function (trigger) {
            return trigger.nextElementSibling
        }
    });
    function wait(callback, seconds) {
        var timelag = null;
        timelag = window.setTimeout(callback, seconds)
    }
    function pjax_initCopyCode() {
		if($(".highlight .code pre").length+$(".article pre code").length==0)return;
        var copyHtml = '';
        copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
        copyHtml += '<i class="fas fa-copy"></i><span>COPY</span>';
        copyHtml += '</button>';
        $(".highlight .code pre").before(copyHtml);
        $(".article pre code").before(copyHtml);
        clipboard.off('success').on('success', function (e) {
            $.message({
            title: '复制成功',
            message: "代码已复制，请遵守相关授权协议。",
            type: 'success'
        });
            let $btn = $(e.trigger);
            $btn.addClass('copied');
            let $icon = $($btn.find('i'));
            $icon.removeClass('fa-copy');
            $icon.addClass('fa-check-circle');
            let $span = $($btn.find('span'));
            $span[0].innerText = 'COPIED';
            wait(function () {
                $icon.removeClass('fa-check-circle');
                $icon.addClass('fa-copy');
                $span[0].innerText = 'COPY'
            }, 2000)
        });
        clipboard.off('error').on('error', function (e) {
            e.clearSelection();
            let $btn = $(e.trigger);
            $btn.addClass('copy-failed');
            let $icon = $($btn.find('i'));
            $icon.removeClass('fa-copy');
            $icon.addClass('fa-times-circle');
            let $span = $($btn.find('span'));
            $span[0].innerText = 'COPY FAILED';
            wait(function () {
                $icon.removeClass('fa-times-circle');
                $icon.addClass('fa-copy');
                $span[0].innerText = 'COPY'
            }, 2000)
        })
    }
    $(function () {
        pjax_initCopyCode()
    });
</script>




   <script src="https://cdn.jsdelivr.net/npm/scrollreveal@4.0.6/dist/scrollreveal.min.js"></script>
<script type="text/javascript">
  function pjax_scrollrebeal() {
    ScrollReveal().reveal('.l_main .reveal', {
      distance: '32px',
      duration: '800',
      interval: '20',
      scale: '1',
      easing: 'ease-out'
    });
  }
  $(function () {
    pjax_scrollrebeal();
  });
</script>




  <script>
  let APlayerController = new Object();
  APlayerController.id = '5229739363';  // 设定全局音乐播放ID
  APlayerController.volume = '0.3';
  APlayerController.autoPlay = 'true';
</script>

  
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10/dist/APlayer.min.js"></script>


  
<script src="https://cdn.jsdelivr.net/npm/meting@2.0/dist/Meting.min.js"></script>




  
<script src="/js/aplayer.js"></script>






  <!--https://cdn.jsdelivr.net/npm/leancloud-storage@3/dist/av-min.js-->
<script src="https://cdn.jsdelivr.net/npm/leancloud-storage@3/dist/av-min.js"></script>

  
<script src="https://cdn.jsdelivr.net/npm/valine@1.4/dist/Valine.min.js"></script>


<script>
  var GUEST_INFO = ['nick', 'mail', 'link'];
  var meta = 'nick,mail,link'.split(',').filter(function (item) {
    return GUEST_INFO.indexOf(item) > -1
  });
  var REQUIRED_FIELDS = ['nick', 'mail', 'link'];
  var requiredFields = 'nick,mail'.split(',').filter(function (item) {
    return REQUIRED_FIELDS.indexOf(item) > -1
  });

  function emoji(path, idx, ext) {
    return path + "/" + path + "-" + idx + "." + ext;
  }

  var emojiMaps = {};
  for (var i = 1; i <= 54; i++) {
    emojiMaps['tieba-' + i] = emoji('tieba', i, 'png');
  }
  for (var i = 1; i <= 101; i++) {
    emojiMaps['qq-' + i] = emoji('qq', i, 'gif');
  }
  for (var i = 1; i <= 116; i++) {
    emojiMaps['aru-' + i] = emoji('aru', i, 'gif');
  }
  for (var i = 1; i <= 125; i++) {
    emojiMaps['twemoji-' + i] = emoji('twemoji', i, 'png');
  }
  for (var i = 1; i <= 4; i++) {
    emojiMaps['weibo-' + i] = emoji('weibo', i, 'png');
  }

  function pjax_valine() {
    if(!document.querySelectorAll("#valine_container")[0])return;

    let pagePlaceholder = $.trim($('#pjax-comment-placeholder').text()) || "嗨,请不要吝啬你的想法！小技巧：在昵称位置输入QQ号就可以自动补全邮箱哦~";

    let path = $.trim($('#pjax-comment-path').text());
    if (path.length == 0) {
      let defaultPath = '';
      path = defaultPath || decodeURI(window.location.pathname);
    }

    var valine = new Valine();
    valine.init({
      el: '#valine_container',
      meta: meta,
      placeholder: pagePlaceholder,
      path: path,
      appId: "i1I90mFU8urYjNXgiqPT05Jt-gzGzoHsz",
      appKey: "GXgwCzMM0g2CnM8x0WCM7fPQ",
      pageSize: '5',
      avatar: 'robohash',
      lang: 'zh-cn',
      visitor: 'true',
      highlight: 'true',
      mathJax: 'false',
      enableQQ: 'true',
      requiredFields: requiredFields,
      emojiCDN: 'https://cdn.jsdelivr.net/gh/volantis-x/cdn-emoji/valine/',
      emojiMaps: emojiMaps
    })
  }

  function newcomment() {

    function queryLeanCloud(k) {
      let root = this;
      let len = arguments.length;
      if (len == 1) {
        let notExist = new AV.Query("Comment");
        notExist.doesNotExist('rid');
        let isEmpty = new AV.Query("Comment");
        isEmpty.equalTo('rid', '');
        let q = AV.Query.or(notExist, isEmpty);
        if (k === '*') q.exists('url');
        else q.equalTo('url', decodeURI(k));
        q.addDescending('createdAt');
        q.addDescending('insertedAt');
        return q;
      } else {
        let ids = JSON.stringify(arguments[1]).replace(/(\[|\])/g, '');
        let cql = `select * from ${root['config']['clazzName']} where rid in (${ids}) order by -createdAt,-createdAt`;
        return AV.Query.doCloudQuery(cql)
      }
    }
    var valine = new Valine({
      el: '#valine_container_ba（因为主题已经有valine的这些参数了，这里随意填都行）',
      app_id: 'i1I90mFU8urYjNXgiqPT05Jt-gzGzoHsz',
      app_key: 'GXgwCzMM0g2CnM8x0WCM7fPQ',
      placeholder: '',
      serverURLs: 'https://i1i90mfu.lc-cn-n1-shared.com'
    });

    //判断博主，heson改为自己的昵称
    function bozhu(e){
      if (e == "Jack"){
        nick = e + '[博主]'
        return nick;
      } else {
        return e
      }
    }

    //判断网址
    function wangzhi(e){
      http = e.slice(0,4)
      https = e.slice(0,5)
      if (http == "http" || https == "https" ){
        return e
      } else if (e == "" || e == null || e == undefined){
        return e
      } else {
        e = 'http://'+ e
        return e
      }
    }

    //查询评论
    valine.Q('*').limit(7).find().then(function (comments) {
      var hotComments = $("#hot-comments");
      for (var i = 0; i < comments.length; i++) {
        if (i === 0) {
          // console.log(comments[0]);
          console.log("\n %c DataScience %c https://www.a2data.cn \n", "color: #fadfa3; background: #030307; padding:5px 0;", "background: #fadfa3; padding:5px 0;"),
          window.customElements && !window.customElements.get("meting-js") && (window.MetingJSElement = MetingJSElement,
                  window.customElements.define("meting-js", MetingJSElement));

        }
        var nick = bozhu(comments[i]._serverData.nick);
        var content = comments[i]._serverData.comment;
        // var newcontent = content.substring(0, 50).replace(/<[^>]+>/g,"");
        var newcontent = content.replace(/<[^>]+>/g,"").replace(/:.*?:/g,"[表情]").substring(0,50);
        var url = comments[i]._serverData.url;
        var link = wangzhi(comments[i]._serverData.link);
        var updatedAt = timeago(comments[i].updatedAt);
        var commentId = '#' + comments[i].id;
        hotComments.append('<div class="card-comment-item"><div class="item-header-text"><a href="'+ link +'" target="_blank" rel="nofollow noopener noreferrer" class="newcomment" >' + nick + '</a>&nbsp;发表于' + updatedAt + '</div><div class="item-text"><a href="' + url + commentId +'"  rel="nofollow" style="color:#717171" class="comments-detail" >' + newcontent + '</a></div></div>');
      }
    });
  };

  $(function () {
    pjax_valine();
    newcomment();
  });
</script>







  <script defer src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-busuanzi@2.3/js/busuanzi.pure.mini.js" data-pjax></script>


  
<script src="/js/app.js"></script>




  
    
<script src="/js/search.js"></script>

  


<!-- optional -->

  <script>
const SearchServiceimagePath="https://cdn.jsdelivr.net/gh/volantis-x/cdn-volantis@master/img/";
const ROOT =  ("/" || "/").endsWith('/') ? ("/" || "/") : ("//" || "/" );
(function ($) {
  
    customSearch = new HexoSearch({
      imagePath: SearchServiceimagePath
    });
  
})(jQuery);

</script>







  
<script src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-volantis@2/js/comment_typing.js"></script>




  
    
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.18.1/build/highlight.min.js"></script>

    <script>hljs.initHighlightingOnLoad();</script>
  



  <script defer>

  const LCCounter = {
    app_id: 'Fsrd5NtVW8ovmaynVJ18xHO6-gzGzoHsz',
    app_key: 'QYc2X76ulK8THVLHwpJfvsrG',
    custom_api_server: '',

    // 查询存储的记录
    getRecord(Counter, url, title) {
      return new Promise(function (resolve, reject) {
        Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify({url})))
          .then(resp => resp.json())
          .then(({results, code, error}) => {
            if (code === 401) {
              throw error;
            }
            if (results && results.length > 0) {
              var record = results[0];
              resolve(record);
            } else {
              Counter('post', '/classes/Counter', {url, title: title, times: 0})
                .then(resp => resp.json())
                .then((record, error) => {
                  if (error) {
                    throw error;
                  }
                  resolve(record);
                }).catch(error => {
                console.error('Failed to create', error);
                reject(error);
              });
            }
          }).catch((error) => {
          console.error('LeanCloud Counter Error:', error);
          reject(error);
        });
      })
    },

    // 发起自增请求
    increment(Counter, incrArr) {
      return new Promise(function (resolve, reject) {
        Counter('post', '/batch', {
          "requests": incrArr
        }).then((res) => {
          res = res.json();
          if (res.error) {
            throw res.error;
          }
          resolve(res);
        }).catch((error) => {
          console.error('Failed to save visitor count', error);
          reject(error);
        });
      });
    },

    // 构建自增请求体
    buildIncrement(objectId) {
      return {
        "method": "PUT",
        "path": `/1.1/classes/Counter/${ objectId }`,
        "body": {
          "times": {
            '__op': 'Increment',
            'amount': 1
          }
        }
      }
    },

    // 校验是否为有效的 UV
    validUV() {
      var key = 'LeanCloudUVTimestamp';
      var flag = localStorage.getItem(key);
      if (flag) {
        // 距离标记小于 24 小时则不计为 UV
        if (new Date().getTime() - parseInt(flag) <= 86400000) {
          return false;
        }
      }
      localStorage.setItem(key, new Date().getTime().toString());
      return true;
    },

    addCount(Counter) {
      var enableIncr = '' === 'true' && window.location.hostname !== 'localhost';
      enableIncr = true;
      var getterArr = [];
      var incrArr = [];
      // 请求 PV 并自增
      var pvCtn = document.querySelector('#lc-sv');
      if (pvCtn || enableIncr) {
        var pvGetter = this.getRecord(Counter, 'http://www.a2data.cn' + '/#lc-sv', 'Visits').then((record) => {
          incrArr.push(this.buildIncrement(record.objectId))
          var eles = document.querySelectorAll('#lc-sv #number');
          if (eles.length > 0) {
            eles.forEach((el,index,array)=>{
              el.innerText = record.times + 1;
              if (pvCtn) {
                pvCtn.style.display = 'inline';
              }
            })
          }
        });
        getterArr.push(pvGetter);
      }

      // 请求 UV 并自增
      var uvCtn = document.querySelector('#lc-uv');
      if (uvCtn || enableIncr) {
        var uvGetter = this.getRecord(Counter, 'http://www.a2data.cn' + '/#lc-uv', 'Visitors').then((record) => {
          var vuv = this.validUV();
          vuv && incrArr.push(this.buildIncrement(record.objectId))
          var eles = document.querySelectorAll('#lc-uv #number');
          if (eles.length > 0) {
            eles.forEach((el,index,array)=>{
              el.innerText = record.times + (vuv ? 1 : 0);
              if (uvCtn) {
                uvCtn.style.display = 'inline';
              }
            })
          }
        });
        getterArr.push(uvGetter);
      }

      // 请求文章的浏览数，如果是当前页面就自增
      var allPV = document.querySelectorAll('#lc-pv');
      if (allPV.length > 0 || enableIncr) {
        for (i = 0; i < allPV.length; i++) {
          let pv = allPV[i];
          let title = pv.getAttribute('data-title');
          var url = 'http://www.a2data.cn' + pv.getAttribute('data-path');
          if (url) {
            var viewGetter = this.getRecord(Counter, url, title).then((record) => {
              // 是当前页面就自增
              let curPath = window.location.pathname;
              if (curPath.includes('index.html')) {
                curPath = curPath.substring(0, curPath.lastIndexOf('index.html'));
              }
              if (pv.getAttribute('data-path') == curPath) {
                incrArr.push(this.buildIncrement(record.objectId));
              }
              if (pv) {
                var ele = pv.querySelector('#lc-pv #number');
                if (ele) {
                  if (pv.getAttribute('data-path') == curPath) {
                    ele.innerText = (record.times || 0) + 1;
                  } else {
                    ele.innerText = record.times || 0;
                  }
                  pv.style.display = 'inline';
                }
              }
            });
            getterArr.push(viewGetter);
          }
        }
      }

      // 如果启动计数自增，批量发起自增请求
      if (enableIncr) {
        Promise.all(getterArr).then(() => {
          incrArr.length > 0 && this.increment(Counter, incrArr);
        })
      }

    },


    fetchData(api_server) {
      var Counter = (method, url, data) => {
        return fetch(`${ api_server }/1.1${ url }`, {
          method,
          headers: {
            'X-LC-Id': this.app_id,
            'X-LC-Key': this.app_key,
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(data)
        });
      };
      this.addCount(Counter);
    },

    refreshCounter() {
      var api_server = this.app_id.slice(-9) !== '-MdYXbMMI' ? this.custom_api_server : `https://${ this.app_id.slice(0, 8).toLowerCase() }.api.lncldglobal.com`;
      if (api_server) {
        this.fetchData(api_server);
      } else {
        fetch('https://app-router.leancloud.cn/2/route?appId=' + this.app_id)
          .then(resp => resp.json())
          .then(({api_server}) => {
            this.fetchData('https://' + api_server);
          });
      }
    }

  };

  LCCounter.refreshCounter();

  document.addEventListener('pjax:complete', function () {
    LCCounter.refreshCounter();
  });
</script>



<!-- more -->


    
      


<script src="https://cdn.jsdelivr.net/npm/pjax@0.2.8/pjax.min.js"></script>

<!-- 样式位于：source/css/_third-party/pjaxanimate.styl -->

<div class="pjax-animate">
  
    <script src="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.js"></script>
    <div id="loading-bar-wrapper"><script>NProgress.configure({parent:"#loading-bar-wrapper",trickleSpeed: 100})</script></div>
    <script>
      window.ShowLoading = function() {
        NProgress.start();
      };
      window.HideLoading = function() {
        NProgress.done();
      }
    </script>
  
</div>

<script>
    var pjax;
    document.addEventListener('DOMContentLoaded', function () {
      pjax = new Pjax({
        elements: 'a[href]:not([href^="#"]):not([href="javascript:void(0)"]):not([pjax-fancybox])',
        selectors: [
          "title",
          "#pjax-container",
          "#pjax-header-nav-list"
        ],
        cacheBust: false,   // url 地址追加时间戳，用以避免浏览器缓存
        timeout: 5000
      });
    });

    document.addEventListener('pjax:send', function (e) {
      window.stop(); // 相当于点击了浏览器的停止按钮

      try {
        var currentUrl = window.location.pathname;
        var targetUrl = e.triggerElement.href;
        var banUrl = ["/Creator-said/"];
        if (banUrl[0] != "") {
          banUrl.forEach(item => {
            if(currentUrl.indexOf(item) != -1 || targetUrl.indexOf(item) != -1) {
              window.location.href = targetUrl;
            }
          });
        }
      } catch (error) {}

      window.subData = null; // 移除标题（用于一二级导航栏切换处）
      if (typeof $.fancybox != "undefined") {
        $.fancybox.close();    // 关闭弹窗
      }
      $('.l_header .switcher .s-search').removeClass('active'); // 关闭移动端激活的搜索框
      $('.l_header').removeClass('z_search-open'); // 关闭移动端激活的搜索框
      $('.wrapper').removeClass('sub'); // 跳转页面时关闭二级导航

      // 解绑事件 避免重复监听
      $('.s-top').unbind('click');
      $('.menu a').unbind('click');
      $(window).unbind('resize');
      $(window).unbind('scroll');
      $(document).unbind('scroll');
      $(document).unbind('click');
      $('body').unbind('click');
      window.ShowLoading();
    });

    document.addEventListener('pjax:complete', function () {
      // 关于百度统计对 SPA 页面的处理：
      // 方案一：百度统计>管理>单页应用设置中，打开开启按钮即可对SPA进行统计。 https://tongji.baidu.com/web/help/article?id=324
      // 方案二：取消注释下列代码。 https://tongji.baidu.com/web/help/article?id=235
      // 

      // 关于谷歌统计对 SPA 页面的处理：
      // 当应用以动态方式加载内容并更新地址栏中的网址时，也应该更新通过 gtag.js 存储的网页网址。
      // https://developers.google.cn/analytics/devguides/collection/gtagjs/single-page-applications?hl=zh-cn
      

      $('.nav-main').find('.list-v').not('.menu-phone').removeAttr("style",""); // 移除小尾巴的移除
      $('.menu-phone.list-v').removeAttr("style",""); // 移除小尾巴的移除
      $('script[data-pjax], .pjax-reload script').each(function () {
        $(this).parent().append($(this).remove());
      });
      try{
          if (typeof $.fancybox == "undefined") {
            SCload_fancybox();
          } else {
            pjax_fancybox();
            newcomment();
          }
        
        
        document.querySelectorAll('pre code').forEach((block) => {
          hljs.highlightBlock(block);
        });
        
        
          pjax_scrollrebeal();
        
        
          pjax_initCopyCode();
        
        
          pjax_valine();
        
        
        
        
        
      } catch (e) {
        console.log(e);
      }
      window.HideLoading();
    });

    document.addEventListener('pjax:error', function (e) {
      window.HideLoading();
      window.location.href = e.triggerElement.href;
    });
</script>

    

      <!--聊天-->

      <script type="text/javascript">window.$crisp=[];window.CRISP_WEBSITE_ID="9e16adc4-63cc-4958-bf99-26d19bf0ede8";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();</script>

      <!--    title 变化-->
      <script type="text/javascript">
        var OriginTitile=document.title,st;
        document.addEventListener("visibilitychange",function(){
          document.hidden?(document.title="ヽ(●-`Д´-)ノ嗨说你呢，别分心",clearTimeout(st)):(document.title="(Ő∀Ő3)ノ欢迎回来！",st=setTimeout(function(){document.title=OriginTitile},3e3))
        })
      </script>

  </div>
</body>
</html>
